home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / LIB211.ZIP;1 / PROC.PRG < prev    next >
Encoding:
Text File  |  1993-12-15  |  103.7 KB  |  2,620 lines

  1. *-- PROGRAM.....: PROC.PRG 
  2. *-----------------------------------------------------------------------
  3. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  4. *-- Date........: 11/22/1993
  5. *-- Version.....: See WHATS.NEW and README.TXT files (both 
  6. *--               ASCII), both files uploaded with this file in one
  7. *--               zipped file.
  8. *-- Notes.......: This procedure file is part of the new and improved 
  9. *--               set of files, re-designed for dBASE IV, 2.0. The 
  10. *--               complete set is contained in the file: LIB211.ZIP. 
  11. *--               Please read README.TXT for all instructions.
  12. *=======================================================================
  13.  
  14. *=======================================================================
  15. * MESSAGE/SCREEN PROCESSING ROUTINES -- includes message boxes, 
  16. * shadowing, and centering of text ... Anything not here is in the 
  17. * library files SCREEN.PRG or DIALOGS.PRG
  18. *=======================================================================
  19.  
  20. PROCEDURE PrintErr
  21. *-----------------------------------------------------------------------
  22. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  23. *-- Date........: 05/24/1991
  24. *-- Notes.......: Used to display a printer error for STAND-ALONE
  25. *--               systems. (The dBASE function PRINTSTATUS() doesn't 
  26. *--               work well on a Network with Print Spoolers ...)
  27. *-- Written for.: dBASE IV, 1.1
  28. *-- Rev. History: 05/24/1991 -- Original
  29. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  30. *--               CENTER               Procedure in PROC.PRG
  31. *-- Called by...: Any
  32. *-- Usage.......: do printerr
  33. *-- Example.....: do setprint  && if it hasn't been done
  34. *--               if .not. printstatus()
  35. *--                  DO PRINTERR
  36. *--               endif
  37. *--               *    or
  38. *--               do while .not. printstatus() && my preference ... 
  39. *--                  DO PRINTERR
  40. *--               enddo
  41. *-- Returns.....: None
  42. *-- Parameters..: None
  43. *-----------------------------------------------------------------------
  44.  
  45.    private cColor, cDummy, cCursor
  46.    
  47.    if iscolor()    && if we're using a color monitor, use yellow on red
  48.       m->cColor = "RG+/R,RG+/R,RG+/R"
  49.    else            && otherwise, use black on white
  50.       m->cColor = "N/W,N/W,N/W"
  51.    endif
  52.    
  53.    activate screen
  54.    define window wPErr from  7,15 to 16,57 double color &cColor.
  55.    save screen to sPErr       && store current screen
  56.    do shadow with 7,15,16,57  && shadow box!
  57.    activate window wPErr      && here we go ..
  58.    
  59.    m->cCursor=set("CURSOR")   && save cursor setting
  60.    set cursor off             && turn cursor off
  61.                               && display message
  62.    do center with 0,40,"",chr(7) + "*** PRINTER ERROR ***"
  63.    do center with 2,40,""," The printer is not ready. Please check:"
  64.    do center with 3,40,"","1) that the printer is ON,        "
  65.    do center with 4,40,"","2) that the printer is ONLINE, and"
  66.    do center with 5,40,"","3) that the printer has paper.    "
  67.    do center with 7,40,"","Press any key to continue . . ."
  68.    
  69.    m->cDummy=inkey(0)         && wait for user to press a key ...
  70.    set cursor &cCursor.       && set cursor to original setting ...
  71.  
  72.   *-- cleanup
  73.    release window wPErr
  74.    restore screen from sPErr
  75.    release screen sPErr
  76.    
  77. RETURN  
  78. *-- EoP: PrintErr
  79.  
  80. PROCEDURE Open_Screen
  81. *-----------------------------------------------------------------------
  82. *-- Programmer..: Rick Price (HAMMETT)
  83. *-- Date........: 05/24/1991
  84. *-- Notes.......: Used to give a texture to the background of the screen
  85. *--               I got this from Rick when he uploaded it as part of 
  86. *--               his original entry to a Color Contest on the ATBBS. It 
  87. *--               is kinda nice to have that texture on the screen, 
  88. *--               keeps it from being monotonous.
  89. *-- Written for.: dBASE IV, 1.1
  90. *-- Rev. History: 05/24/1991 -- Original
  91. *-- Calls.......: None
  92. *-- Called by...: Any
  93. *-- Usage.......: do open_screen
  94. *-- Example.....: do open_screen
  95. *-- Returns.....: None
  96. *-- Parameters..: None
  97. *-----------------------------------------------------------------------
  98.  
  99.    private nRow, cBackDrp, nHoldRow
  100.    
  101.    clear
  102.    m->nRow=0
  103.    m->cBackDrp = chr(176)  && chr(176)="∞",chr(177)="±",chr(178)="≤"
  104.    do while m->nRow < 3
  105.       @m->nRow,0 to m->nRow+3,79 m->cBackDrp  
  106.                                   && fill this section of the screen
  107.       m->nHoldRow = m->nRow
  108.       m->nRow = m->nRow + 6
  109.       @m->nRow,0 to m->nRow+3,79 m->cBackDrp
  110.       m->nRow = m->nRow + 6
  111.       @m->nRow,0 to m->nRow+3,79 m->cBackDrp
  112.       m->nRow = m->nRow + 6
  113.       @m->nRow,0 to m->nRow+3,79 m->cBackDrp
  114.       m->nRow = m->nHoldRow + 1
  115.    enddo
  116.    @24,0 to 24,79 m->cBackDrp
  117.  
  118. RETURN
  119. *-- EoP: OpenScreen
  120.  
  121. PROCEDURE NewBack
  122. *-----------------------------------------------------------------------
  123. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  124. *-- Date........: 06/11/1993
  125. *-- Notes.......: Based on some ideas from Mike Irwin's presentation at 
  126. *--               the 4th Annual Borland International Conference (Tips 
  127. *--               and Tricks), this routine will provide a textured 
  128. *--               background surface using the current colors for the 
  129. *--               background, and three ascii high order characters 
  130. *--               (176,177,178). It will handle different screen sizes 
  131. *--               (i.e., 25 line, 43 line and 50 line).
  132. *--               WARNING: This routine assumes that the status line is
  133. *--               turned off.
  134. *-- Written for.: dBASE IV, 1.5
  135. *-- Rev. History: 06/11/1993 -- Original
  136. *-- Calls.......: None
  137. *-- Called by...: Any
  138. *-- Usage.......: do NewBack
  139. *-- Example.....: do NewBack
  140. *-- Returns.....: None
  141. *-- Parameters..: None
  142. *-----------------------------------------------------------------------
  143.    
  144.    private cScrType, nScrHeight, cString, nTimes, nTop, nBottom, nCount
  145.  
  146.    m->cString = replicate("∞±≤",80)  && 240 = 80 characters
  147.                                      && times three lines
  148.    m->cString2 = replicate("∞±≤",26)+"∞±"  && bottom row ...
  149.    m->cString3 = replicate("≤∞±",26)+"≤±"  && bottom for 50 line mode
  150.  
  151.    *-- get the screen height -- if we have a mono monitor, it is, 
  152.    *-- by definition, 25 lines.
  153.    m->cScrType = set("DISPLAY")
  154.    if m->cScrType = "MONO"
  155.       m->nScrHeight = 25
  156.    else
  157.       m->nScrHeight = val(right(m->cScrType,2))
  158.    endif
  159.    m->nScreen    = m->nScrHeight
  160.    m->nScrHeight = m->nScrHeight - 1  && start at 0, remember!
  161.    
  162.    *-- now, how to deal with the display? We want to do a routine where 
  163.    *-- we display one set at the top, one at the bottom, and back to 
  164.    *-- the top. This tricks the eye into thinking that it's happening 
  165.    *-- all at once, rather than top to bottom ...
  166.    if m->nScrHeight/3 = int(m->nScrHeight/3)
  167.       m->nTimes = m->nScrHeight/3
  168.    else
  169.       m->nScrHeight = m->nScrHeight - 1
  170.       if m->nScrHeight/3 = int(m->nScrHeight/3)
  171.          m->nTimes = m->nScrHeight/3
  172.       else
  173.          m->nScrHeight = m->nScrHeight - 1
  174.          m->nTimes = m->nScrHeight/3
  175.       endif
  176.    endif
  177.    m->nTimes = m->nTimes / 2
  178.    
  179.    *-- Now for a display loop ... 
  180.    m->nTop = 0
  181.    m->nBottom = m->nScrHeight - 3
  182.    m->nCount = 0
  183.    do while m->nCount < m->nTimes
  184.       m->nCount = m->nCount + 1
  185.       @   m->nTop,0 say m->cString
  186.       @m->nBottom,0 say m->cString
  187.       m->nTop    = m->nTop + 3
  188.       m->nBottom = m->nBottom - 3
  189.    enddo
  190.    do case
  191.       case m->nScreen = 25 .or. m->nScreen = 43
  192.          @m->nScreen-1,0 say m->cString2
  193.       case m->nScreen = 50
  194.          @48,0 say m->cString2
  195.          @49,0 say m->cString3
  196.    endcase
  197.    
  198. RETURN
  199. *-- EoP: NewBack
  200.  
  201. PROCEDURE JazClear
  202. *-----------------------------------------------------------------------
  203. *-- Programmer..: Rick Price (HAMMETT)
  204. *-- Date........: 05/24/1991
  205. *-- Notes.......: Used to clear the screen from the middle out --
  206. *--               could be used with OpenScreen, above. I got this
  207. *--               from Rick at the same time I got the other routine 
  208. *--               above ... This requires a full screen (0,0 to 
  209. *--               23,79 ...)
  210. *-- Written for.: dBASE IV, 1.1
  211. *-- Rev. History: 05/24/1991 -- Original
  212. *-- Calls.......: None
  213. *-- Called by...: Any
  214. *-- Usage.......: do jazclear
  215. *-- Examples....: do jazclear
  216. *-- Returns.....: None
  217. *-- Parameters..: None
  218. *-----------------------------------------------------------------------
  219.  
  220.    private nWinR1, nWinR2, nWinC1, nWinC2, nStep, mnWinC1, mnWinC2, ;
  221.       mnWinR1, mnWinR2, nStep, nTmpAdjR, nTmpAdjC, nAdjRow, nAdjCol
  222.    private nColLeft, nColRite, nRowTop, nRowBot
  223.    
  224.    m->nWinR1 = 0   && row 1
  225.    m->nWinR2 = 24  && row 2
  226.    m->nWinC1 = 0   && column 1
  227.    m->nWinC2 = 79  && column 2
  228.    m->nStep = 1    && amount to increment by
  229.      * set starting point
  230.    m->mnWinC1 = int((m->nWinC2-m->nWinC1)/2)+m->nWinC1
  231.    m->mnWinC2 = m->mnWinC1+1
  232.    m->mnWinR1 = int((m->nWinR2-m->nWinR1)/2)+m->nWinR1
  233.    m->mnWinR2 = m->mnWinR1+1
  234.    
  235.    ** Adjust step offset values: nColOff & m->nRowOff
  236.    ** Vertical steps: m->nWinR1-m->nWinR1
  237.    m->nTmpAdjR = int((m->nWinR2 - m->nWinR1)/2)
  238.    m->nTmpAdjC = int((m->nWinC2 - m->nWinC1)/2)
  239.    
  240.    nAdjRow = ;
  241.     iif(m->nTmpAdjC > m->nTmpAdjR, m->nTmpAdjR/m->nTmpAdjC,1) * m->nStep
  242.    
  243.    nAdjCol = ;
  244.       iif(m->nTmpAdjR > m->nTmpAdjC, m->nTmpAdjC/m->nTmpAdjR,1) * ;
  245.           m->nStep
  246.    
  247.    m->nColLeft = m->nWinC1
  248.    m->nColRite = m->nWinC2
  249.    m->nRowTop = m->nWinR1
  250.    m->nRowBot = m->nWinR2
  251.    m->nWinC1 = m->mnWinC1
  252.    m->nWinC2 = m->mnWinC2
  253.    m->nWinR1 = m->mnWinR1
  254.    m->nWinR2 = m->mnWinR2
  255.    do while (m->nWinC1#m->nColLeft .or. m->nWinC2#m->nColRite .or. ;
  256.       m->nWinR1 # m->nRowTop .or. m->nWinR2 # m->nRowBot)
  257.       
  258.       * Adjust coordinates for the clear (moving out from the middle)
  259.       m->nWinR1 = ;
  260.         m->nWinR1-iif(m->nRowTop<m->nWinR1-nAdjRow,nAdjRow,;
  261.         m->nWinR1-m->nRowTop)
  262.       m->nWinR2 = ;
  263.         m->nWinR2+iif(m->nRowBot>m->nWinR2+nAdjRow,nAdjRow,;
  264.         m->nRowBot-m->nWinR2)
  265.       m->nWinC1 = ;
  266.         m->nWinC1-iif(m->nColLeft<m->nWinC1-nAdjCol,nAdjCol,;
  267.         m->nWinC1-m->nColLeft)
  268.       m->nWinC2 = ;
  269.         m->nWinC2+iif(m->nColRite>m->nWinC2+nAdjCol,nAdjCol,;
  270.         m->nColRite-m->nWinC2)
  271.       
  272.       * Perform the clear
  273.       @m->nWinR1,m->nWinC1 clear to m->nWinR2,m->nWinC2
  274.       @m->nWinR1,m->nWinC1 to m->nWinR2,m->nWinC2
  275.    enddo
  276.    clear
  277.    
  278. RETURN   
  279. *-- EoP: JazClear
  280.  
  281. PROCEDURE Wipe
  282. *-----------------------------------------------------------------------
  283. *-- Programmer..: Alan D. Frazier (CALLAE)
  284. *-- Date........: 01/10/1992
  285. *-- Notes.......: Used to wipe a window from left to right. Nice effect.
  286. *--               Parameters are the coordinates of the window ...
  287. *-- Written for.: dBASE IV, 1.1
  288. *-- Rev. History: 01/10/1992 -- Original
  289. *-- Calls.......: None
  290. *-- Called by...: Any
  291. *-- Usage.......: do Wipe with <nULRow>,<nULCol>,<nBRRow>,<nBRCol>
  292. *-- Example.....: define window test from 5,10 to 20,70
  293. *--               activate window test
  294. *--                   *-- do stuff in window
  295. *--               do Wipe with 5,10,20,70
  296. *-- Returns.....: None
  297. *-- Parameters..: nULRow = Upper (Left) Row
  298. *--               nULCol = (Upper) Left Column
  299. *--               nBRRow = Bottom (Right) Row
  300. *--               nBRCol = (Bottom) Right Column
  301. *-----------------------------------------------------------------------
  302.  
  303.     parameter nULRow,nULCol,nBRRow,nBRCol
  304.  
  305.     private nULRow,nULCol,nBRRow,nBRCol,nCurLeft
  306.  
  307.     m->nCurLeft = 0    && always start at column 0 within the window
  308.     m->nBRRow  = m->nBRRow - m->nULRow - 2
  309.     m->nBRCol =  m->nBRCol - m->nULCol - 2
  310.  
  311.     do while m->nCurLeft+2 < m->nBRCol
  312.        @ 0,m->nCurLeft clear to m->nBRRow,m->nCurLeft + 2
  313.        m->nCurLeft = m->nCurLeft  + 2
  314.     enddo
  315.  
  316.     @ 0,m->nBRCol-2 CLEAR TO m->nBRRow,m->nBRCol - 1
  317.  
  318. RETURN
  319. *-- EoP: Wipe
  320.  
  321. PROCEDURE Center
  322. *-----------------------------------------------------------------------
  323. *-- Programmer..: Miriam Liskin
  324. *-- Date........: 05/24/1991
  325. *-- Notes.......: Centers text on the screen with @says
  326. *-- Written for.: dBASE IV, 1.1
  327. *-- Rev. History: This and all other procedures/functions listed in this
  328. *--               file attributed to Miriam Liskin came from "Liskin's
  329. *--               Programming dBASE IV Book". Highly Recommended.
  330. *-- Calls.......: None
  331. *-- Called by...: Any
  332. *-- Usage.......: do center with <nLine>,<nWidth>,"<cColor>","<cText>"
  333. *-- Example.....: do center with 5,65,"RG+/GB",;
  334. *--                               "WARNING! This will blow up!"
  335. *--                  Note that the color field may be blank: ""
  336. *-- Returns.....: None
  337. *-- Parameters..: nLine  = Line or Row for @/Say
  338. *--               nWidth = Width of screen
  339. *--               cColor = Colors to be used ("Forg/Back") 
  340. *--                        (may be nul "", in order to use the default
  341. *--                        colors of window/screen)
  342. *--               cText  = Message to center on screen
  343. *-----------------------------------------------------------------------
  344.    
  345.    parameters nLine,nWidth,cColor,cText
  346.    private nCol
  347.    
  348.    m->nCol = (m->nWidth - len(m->cText)) /2
  349.    @m->nLine,m->nCol say m->cText color &cColor.
  350.    
  351. RETURN
  352. *-- EoP: Center
  353.  
  354. PROCEDURE ProgBar
  355. *-----------------------------------------------------------------------
  356. *-- Programmer..: Joey D. Carroll (JOEY)
  357. *-- Date........: 10/26/1992
  358. *-- Notes.......: A visual indicator of program activity, i.e. shows
  359. *--               user program didn't die during long processes which
  360. *--               do not normally show 'on screen'.  Serves same purpose
  361. *--               as MONITOR, but is more graphic.
  362. *--               For best appearance, set cursor 'off' from calling
  363. *--               program, outside of the loop which calls PROGBAR.
  364. *-- Written for.: dBASE IV, 1.5
  365. *-- Rev. History: 06/28/1992 -- Original
  366. *--               10/26/1992 - Fixed bug(feature) so that cMessage 
  367. *--                 prints the color requested by cWindCol. Protected 
  368. *--                 existing active Window. (Joey Carroll)
  369. *-- Calls.......: None
  370. *-- Called by...: Any
  371. *-- Usage.......: do PROGBAR with <nQuan>,<cWindCol>,<cFillCol1>,;
  372. *--                               <cFillCol2>,<cMessage>,<nWindWidth>
  373. *-- Example.....: *-- determine what process will be monitored and what 
  374. *--               *-- the final value will be, e.g. 
  375. *--               *-- nReccount = reccount()
  376. *--               use <anyfile>
  377. *--               nReccount = reccount()
  378. *--               set cursor off
  379. *--               scan
  380. *--                  do progbar with nReccount,",,w+/n","w+/r","w+/g", ;
  381. *--                     "Processing records.  Be patient.",40
  382. *--                  *-- do some needed process here
  383. *--               endscan
  384. *--               *-- cleanup
  385. *-- Returns.....: None
  386. *-- Parameters..: nQuan     = maximum number of iterations
  387. *--               cWindCol  = the window colors
  388. *--               cFillCol1 = color of ruler before process
  389. *--               cFillCol2 = color of ruler after process
  390. *--               cMessage  = message displayed to user, may be "".
  391. *--               nWindWid  = (optional) desired width of ruler window. 
  392. *--                           If not specified, width of screen.  If
  393. *--                           specified, will not be less than length of
  394. *--                           message.
  395. *-----------------------------------------------------------------------
  396.  
  397.    parameters nQuan,cWindCol,cFillCol1,cFillCol2,cMessage,nWinWidth
  398.    private Message,x, nParms
  399.  
  400.    *-- Was message passed as a parameter?
  401.    m->lMessage  = iif(.not. isblank(m->cMessage), .t., .f.)  
  402.  
  403.    *-- find out # of parameters passed ...
  404.    if val(right(version(),3)) > 1.1
  405.       m->nParms = pcount()
  406.    else
  407.       m->nParms = 6
  408.    endif
  409.  
  410.    *-- all the way if width not passed
  411.    m->nWinWidth = iif(m->nParms = 6,m->nWinWidth,78) 
  412.    *-- width param > 78 not allowed
  413.    m->nWinWidth = min(m->nWinWidth,78) 
  414.    *-- window width can't be narrower than messsage, so....
  415.    m->nWinWidth = iif(m->lMessage,max(m->nWinWidth,len(m->cMessage) +;
  416.                             2),m->nWinWidth)
  417.  
  418.    *-- skip this section if we've been here before
  419.    *-- this procedure called from inside a loop
  420.    *-- following section ignored except on first iteration thru loop
  421.    if type("m->nTimes") = "U"  && check to see if we been here before
  422.        save screen to sProgBar
  423.        *-- make these available on all iterations
  424.        public m->nFactor,m->nTimes,m->wPrevWind  
  425.        *-- was a window active?
  426.        m->wPrevWind = window()
  427.        *-- don't overwrite status
  428.        m->nProgLine = iif(set("status") = "ON",20,22) 
  429.        *-- determine how wide the window needs to be
  430.        define window wProgBar from ;
  431.           m->nProgLine - iif(m->lMessage, 2, 1),(80 - ;
  432.            (m->nWinWidth + 2));
  433.            / 2 to m->nProgLine + 1,(80 + (m->nWinWidth + 2)) / 2 - 1 ;
  434.            double color &cWindCol.
  435.       activate window wProgBar
  436.       @ 0,0 say replicate(".",m->nWinWidth - 1)  && the ruler
  437.       @ 0,0 say "0%"                           && and some gradation %'s
  438.       @ 0,m->nWinWidth / 4 - 2 say "25%"
  439.       @ 0,m->nWinWidth / 2 - 2 say "50%"
  440.       @ 0,3*(m->nWinWidth / 4) - 2 say "75%"
  441.        @ 0,m->nWinWidth - 4 say "100%"
  442.        *-- color of ruler before process
  443.       @ 0,0 fill to 0,m->nWinWidth - 1 color &cFillCol1.
  444.       if m->lMessage
  445.          @ 1,(m->nWinWidth - (len(m->cMessage))) / 2 say m->cMessage 
  446.       endif
  447.       *-- e.g. how many records per bar part(cols)
  448.        m->nFactor = m->nQuan/m->nWinWidth
  449.        m->nTimes = 0  && times thru loop
  450.    endif      && type("nTimes") = "U"
  451.  
  452.    *-- this section will be processed as many times as required by nQuan
  453.    m->nTimes = m->nTimes + 1
  454.    @ 0,0 fill to 0,int(m->nTimes / m->nFactor) ;
  455.             - iif(int(m->nTimes / m->nFactor) - 1 >= 0, 1, 0) ;
  456.             color &cFillCol2. && color of ruler as processing occurs
  457.    if m->nTimes = m->nQuan    && we're done
  458.        x = inkey(.5)   && leave on screen just a liitle while after
  459.                        && completion
  460.       *-- cleanup your mess
  461.       release window wProgBar
  462.       restore screen from sProgBar
  463.       release screen sProgBar
  464.       *-- Reactivate window if it existed
  465.       if .not. isblank(m->wPrevWind)
  466.           activate window &wPrevWind.
  467.       endif
  468.       release m->nFactor,m->nTimes,m->lMessage,x,m->wPrevWind
  469.    endif  && nTimes = nQuan
  470. RETURN
  471. *-- EoP: ProgBar
  472.  
  473. PROCEDURE Shadow
  474. *-----------------------------------------------------------------------
  475. *-- Programmer..: Ashton-Tate
  476. *-- Date........: 06/02/1993
  477. *-- Notes.......: Creates a shadow for a window (taken from the dBASE IV
  478. *--               picklist functions)
  479. *-- Written for.: dBASE IV, 1.1
  480. *-- Rev. History: 05/23/1991 - original procedure.
  481. *--               12/14/1991 - Modified by Jim Magnant (TXAGGIE) - to 
  482. *--                 check for columns exceeding 79, and temporarily 
  483. *--                 change last col. value (so routine doesn't "blow 
  484. *--                 up").
  485. *--               01/27/1992 -- Modifiedy by Ken Mayer to check for 
  486. *--                 bottom of screen, based on what Jim did above. No 
  487. *--                 further than 23.
  488. *--               06/02/1993 -- Modified to handle screens larger than 
  489. *--                 24 lines. (KJM)
  490. *-- Calls.......: None
  491. *-- Called by...: Too many to list ...
  492. *-- Usage.......: do shadow with <nULRow>,<nULCol>,<nBRRow>,<nBRCol>
  493. *-- Example.....: save screen to sMain
  494. *--               activate screen
  495. *--               define window wError from 5,15 to 15,65 double color;
  496. *--                    rg+/r,rg+/r,rg+/r
  497. *--               do shadow with 5,15,15,65
  498. *--               activate window WError
  499. *--                && perform actions in window
  500. *--               release window WError
  501. *--               restore screen from sMain
  502. *--               release screen sMain
  503. *-- Returns.....: None
  504. *-- Parameters..: nULRow = Upper Left Row position
  505. *--               nULCol = Upper Left Column position (x,y)
  506. *--               nBRRow = Bottom Right Row position
  507. *--               nBRCol = Bottom Right Column position (x2,y2)
  508. *-----------------------------------------------------------------------
  509.  
  510.    parameters nULRow,nULCol,nBRRow,nBRCOL
  511.    private nTempRow,nTempCol,nIncRow,nIncCol,cScreen,nScreen
  512.  
  513.    *-- if screen is larger than 24 lines (EGA43, EGA50 ...)
  514.    m->cScreen = set("DISPLAY")
  515.    if m->cScreen = "MONO"
  516.       m->nScreen = 23
  517.    else
  518.       m->nScreen = val(right(m->cScreen,2))-2
  519.    endif
  520.       
  521.    m->nTempRow = iif(m->nBRRow+1>m->nScreen,m->nScreen,m->nBRRow+1)
  522.    m->nTempCol = iif(m->nBRCol+2>79,79,m->nBRCol+2)
  523.    m->nIncRow = 1
  524.    m->nIncCol = (m->nBRCol-m->nULCol) / (m->nBRRow-m->nULRow)
  525.    do while m->nTempRow <> m->nULRow .or. m->nTempCol <> m->nULCol+2
  526.       m->nRightCol = m->nBRCol
  527.       m->nBRCol = iif(m->nBRCol + 2 > 79,77,m->nBRCol)
  528.       m->nBotRow = m->nBRRow
  529.       m->nBRRow = iif(m->nBRRow + 1 > m->nScreen,m->nScreen-1,m->nBRRow)
  530.       @ m->nTempRow,m->nTempCol fill to m->nBRRow+1,m->nBRCol+2 ;
  531.           color n+/n
  532.       m->nBRCol = m->nRightCol
  533.       m->nBRRow = m->nBotRow
  534.       m->nTempRow = iif(m->nTempRow<>m->nULRow,m->nTempRow -m->nIncRow,;
  535.                         m->nTempRow)
  536.       m->nTempCol = iif(m->nTempCol<>m->nULCol+2,m->nTempCol - ;
  537.                         m->nIncCol,m->nTempCol)
  538.       m->nTempCol = iif(m->nTempCol<m->nULCol+2,m->nULCol+2,m->nTempCol)
  539.    enddo
  540.    
  541. RETURN
  542. *-- EoP: Shadow
  543.  
  544. FUNCTION VPick
  545. *-----------------------------------------------------------------------
  546. *-- Programmer..: Keith G. Chuvala (CIS: 71600,2033)
  547. *-- Date........: 06/08/1992
  548. *-- Notes.......: Keith wanted a multiple choice picklist routine for 
  549. *--               use with a mouse (or other) ... he got the idea for 
  550. *--               the AT-USER system which he was Beta Testing. Here 
  551. *--               'tis ... This creates a quick pick-list for 
  552. *--               multiple-choice, single-character input. The first 
  553. *--               letter of the selected bar is returned. If <Esc> is 
  554. *--               pressed, a null string is returned.
  555. *--               NOTE: If using this with dBASE IV, 1.1, you must 
  556. *--               supply a parameter for each option below.
  557. *-- Written for.: dBASE IV, 1.5
  558. *-- Rev. History: 06/02/1992 -- Keith first gave this to Ken Mayer to 
  559. *--                  use with the BORUSER system.
  560. *--               06/08/1992 -- Modified to allow passing of a color 
  561. *--                  memvar, and then to use explicit color definitions
  562. *--                  based on it.
  563. *--               11/09/1992 - Joey Carrol modified to allow use of 
  564. *--                  function when another window is active, and to 
  565. *--                  insure color integrity 
  566. *-- Calls.......: COLORBRK()          Function in PROC.PRG
  567. *--               RECOLOR             Procedure in PROC.PRG
  568. *-- Called by...: Any
  569. *-- Usage.......: ?VPick(<m->nRow>,<nCol>,"<cOptions>","<cTitle>",;
  570. *--                      "<cMessage>",<lShadow>,<cColor>)
  571. *-- Example.....: cHow = VPick(12,15,"~BorBBS ID~Lastname",;
  572. *--                        "How do you want the data sorted?",;
  573. *--                        "Choose one","rg+/gb,w+/b,rg+/gb")
  574. *-- Returns.....: First letter of bar selected, or null if <Esc>.
  575. *-- Parameters..: nRow     = is a numeric value for the top row of the 
  576. *--                          popup.
  577. *--               nCol     = is a numeric value for the left column.
  578. *--               cOptions = is a string of options with each preceded 
  579. *--                          by '~', e.g. "~Screen~Printer~Text File~
  580. *--                          Return to Menu"
  581. *--               cTitle   = is an optional title, used for the popup 
  582. *--                          heading
  583. *--               cMessage = is an optional message string for when 
  584. *--                          the popup is activated on the screen.
  585. *--               lShadow  = is a logical value indicating whether or 
  586. *--                          not a shadow is to be placed under the 
  587. *--                          e.g. how many records per bar part(cols)
  588. *--                          popup.
  589. *--               cColor   = Colors to be used. Should have three parts 
  590. *--                          -- <normal/unselected text>,<highlighted 
  591. *--                          text>,<border>, using the format 
  592. *--                          "Foreground/Background" 
  593. *--                          for each. So examine the example above.
  594. *-----------------------------------------------------------------------
  595.  
  596.    parameters nRow,nCol,cOptions,cTitle,cMessage,lShadow,cColor
  597.    private nRow,nCol,cOptions,cTitle,cMessage,lShadow,cTempCol,cCurColor
  598.    
  599.    *-- get number of parameters, and a few setup steps ...
  600.    if val(right(version(),3)) > 1.1  && if version of dBASE 
  601.                                      && (RunTime) > 1.1
  602.       m->nParameters = pcount()
  603.    else
  604.       m->nParameters = 7
  605.    endif
  606.    m->nCount = 0
  607.    m->cReturn = ""
  608.    m->cOptions = trim(m->cOptions)
  609.    m->cDispMesg = ""
  610.    *-- if number of parameters greater/equal to 5, we may have a message
  611.    *-- at the bottom of the screen ...
  612.    if m->nParameters >= 5
  613.       if len(m->cMessage) > 0
  614.          m->cDispMesg = "MESSAGE "+"'"+m->cMessage+"'"
  615.       endif
  616.    endif
  617.    
  618.    *-- make it work even if a window is active.
  619.    m->wPrevWind = window()
  620.    activate screen
  621.  
  622.    *-- define the popup
  623.    define popup pPickList from m->nRow,m->nCol &cDispMesg.
  624.    m->nMessage1 = 0
  625.    *-- if we have 4 or more parameters, one of them is the title ...
  626.    *-- this requires that the first two bars of the menu be skipped ...
  627.    if m->nParameters >= 4
  628.       if len(m->cTitle) > 0
  629.          m->cTitle = " "+m->cTitle+" "
  630.          m->nMessage1 = len(m->cTitle)
  631.          m->nCount = 2
  632.       endif
  633.    endif
  634.  
  635.    *-- save current colors
  636.    m->cCurColor = set("ATTRIBUTES")
  637.    *-- set new ones
  638.    m->cTempCol = colorbrk(m->cColor,1)
  639.    set color of normal  to &cTempCol.
  640.    set color of message to &cTempCol.
  641.    m->cTempCol = colorbrk(m->cColor,2)
  642.    set color of highlight to &cTempCol.
  643.    m->cTempCol = colorbrk(m->cColor,3)
  644.    set color of box to &cTempCol.
  645.    
  646.    *-- now we start parsing the options for the menu. These must have
  647.    *-- a tilde between each, so we look for the first one, and then
  648.    *-- look again to see if there's another after that.
  649.    m->nPos1 = at("~",m->cOptions)           && Look for first tilde
  650.    do while (len(m->cOptions) > 0) .and. (m->nPos1 > 0)  && parsing loop 
  651.       if m->nPos1 > 0
  652.          m->cSub = substr(m->cOptions,m->nPos1+1,len(m->cOptions)-;
  653.                            m->nPos1)
  654.          m->nPos2 = at("~",m->cSub)
  655.          if m->nPos2 = 0
  656.             m->nPos2 = len(m->cSub)
  657.          else
  658.             m->nPos2 = m->nPos2 - 1
  659.          endif
  660.          m->cOptString = " "+left(m->cSub,m->nPos2)+" "
  661.          if len(m->cOptString) > m->nMessage1
  662.             m->nMessage1 = len(m->cOptString)
  663.          endif
  664.          *-- define the actual 'bar' of the menu/picklist ...
  665.          m->nCount = m->nCount + 1
  666.          define bar m->nCount of pPickList prompt m->cOptString
  667.          m->cOptions = m->cSub
  668.       endif
  669.       m->nPos1 = at("~",m->cOptions)
  670.    enddo  && end of parsing loop
  671.  
  672.    *-- now we deal with defining the actual picklist ...
  673.     if m->nCount > 0             && if we have something to put in the 
  674.                                  && list ...
  675.        if m->nParameters >= 4    && if we have a title for the top ...
  676.           if len(m->cTitle) > 0
  677.              if len(m->cTitle) < m->nMessage1
  678.                 m->cTitle = trim(ltrim(m->cTitle))
  679.                 m->cTitle = space((m->nMessage1-len(m->cTitle)) / 2) +;
  680.                             m->cTitle
  681.             endif
  682.             define bar 1 of pPickList prompt m->cTitle skip
  683.              define bar 2 of pPickList prompt replicate(chr(196),;
  684.                                               m->nMessage1) skip
  685.          endif
  686.       endif
  687.       *-- define what to do when a choice is made ...
  688.       on selection popup pPickList deactivate popup
  689.       *-- if we have a shadow, let's save screen and do the shadow
  690.       *-- before popping up the picklist
  691.       if m->nParameters => 6
  692.          if m->lShadow
  693.             save screen to sPickScr
  694.             @ m->nRow+1,m->nCol+2 fill to m->nRow+m->nCount+2,m->nCol+;
  695.                                           m->nMessage1+3 color w/n
  696.          endif
  697.       else
  698.          m->lShadow = .f.
  699.       endif
  700.      *-- there we are ...
  701.      activate popup pPickList
  702.  
  703.       *-- cleanup
  704.       if m->lShadow
  705.          restore screen from sPickScr
  706.          release screen sPickScr
  707.       endif
  708.  
  709.       *-- deal with what to 'return' ...
  710.       if lastkey() = 27
  711.          m->cReturn = ""
  712.       else
  713.          m->cReturn = substr(prompt(),2,1)
  714.       endif
  715.  
  716.    endif && nCount > 0
  717.  
  718.     *-- we're done with it ... return it back to the electronic byte 
  719.     *-- storage bins ... 
  720.    release popup pPickList
  721.    do ReColor with m->cCurColor
  722.    
  723.    *-- was there an existing window?
  724.    if .not. isblank(m->wPrevWind)
  725.       activate window &wPrevWind.
  726.    endif
  727.    
  728. RETURN m->cReturn
  729. *-- EoF: VPick()
  730.  
  731. FUNCTION HPick
  732. *-----------------------------------------------------------------------
  733. *-- Programmer..: Keith G. Chuvala (CIS: 71600,2033)
  734. *-- Date........: 11/09/1992
  735. *-- Notes.......: Creates a horizontal pick list for multiple-choice 
  736. *--               single-character input.  The first letter of the 
  737. *--               selected pad is returned.  If <ESC> is pressed, a 
  738. *--               null string is returned.
  739. *-- Written for.: dBASE IV, 1.1, 1.5
  740. *-- Rev. History: 06/12/1992 -- Original
  741. *--               11/09/1992 - Modified to allow use when another window 
  742. *--                 is active, and to ensure color integrity (Joey 
  743. *--                 Carroll).
  744. *-- Calls.......: COLORBRK()           Function in PROC.PRG
  745. *--               RECOLOR              Procedure in PROC.PRG
  746. *-- Called by...: Any
  747. *-- Usage.......: HPICK(<nRow>,<nCol>,"<cOptions>","<cTitle>",;
  748. *--                                   "<cMessage>",<lShadow>,"<cColor>")
  749. *-- Example.....: x=HPick(8,5,"~Screen~Printer~Text File~Return - Menu",;
  750. *--                     "Output Options","Select one, or <Esc> to exit",;
  751. *--                       .t.,"rg+/gb,w+/b,rg+/gb")
  752. *-- Returns.....: First letter of selected 'pad', or null if <Esc>.
  753. *-- Parameters..: nRow      = a numeric value for the top row of the 
  754. *--                            popup.
  755. *--               nCol      = a numeric value for the left column of the
  756. *--                            popup.
  757. *--               cOptions  = a string of options with each preceded by
  758. *--                            '~', e.g. "~Screen~Printer~Text File~;
  759. *--                            Return to Menu"
  760. *--               cTitle    = an optional title, used for the popup 
  761. *--                            heading
  762. *--               cMessage  = an optional message string for when the 
  763. *--                            popup is activated on the screen.
  764. *--               lShadow   = a logical value indicating whether or not 
  765. *--                            a shadow is to be placed under the popup.
  766. *--               cColor    = Colors passed to function in format:
  767. *--                            <Text/Unselected Pad>,<Selected Pad>,;
  768. *--                            <Border>
  769. *-----------------------------------------------------------------------
  770.  
  771.    parameters nRow,nCol,cOptions,cTitle,cMessage,lShadow, cColor
  772.    private cPickColor,cTempCol
  773.  
  774.    *-- get number of parameters, and a few setup steps
  775.    *-- if version 1.5 or later, # of parms is optional ...
  776.    if val(right(version(),3)) > 1.1  && if version of dBASE > 1.1
  777.       m->nParameters = pcount()
  778.    else
  779.       m->nParameters = 7
  780.    endif
  781.    m->nCount = 0
  782.    m->nStartCol = m->nCol
  783.    m->cOptions = trim(m->cOptions)
  784.    m->cDispMess = ""
  785.    
  786.    *-- make it work even if a window is active
  787.    m->wPrevWind = window()
  788.    activate screen
  789.    
  790.    *-- save current colors, set up colors for this routine
  791.    m->cPickColor = set("ATTRIBUTES")
  792.    m->cTempCol = colorbrk(m->cColor,1)
  793.    set color of normal to &cTempCol.
  794.    set color of message to &cTempCol.
  795.    m->cTempCol = colorbrk(m->cColor,2)
  796.    set color of highlight to &cTempCol.
  797.    m->cTempCol = colorbrk(m->cColor,3)
  798.    set color of box to &cTempCol.
  799.    
  800.    m->cPadName = "p"
  801.    *-- if # of parameters => 5, we may have a message at the bottom of 
  802.    *-- the screen ...
  803.    if m->nParameters >= 5
  804.       if len(m->cMessage) > 0
  805.          m->cDispMess = "MESSAGE "+"'"+m->cMessage+"'"
  806.       endif
  807.    endif
  808.    *-- start defining the menu ...
  809.    define menu mHPick &cDispMess.
  810.    if m->nParameters >= 4
  811.       if len(m->cTitle) > 0
  812.           m->cTitle = " "+m->cTitle+" "
  813.       endif
  814.    endif
  815.    
  816.    *-- here, we have to parse the cOptions field for the tilde "~" 
  817.    *-- character, which is how we know we have a new pad ...
  818.    m->nPos1 = at("~",m->cOptions)             && position of first tilde
  819.    do while (len(m->cOptions) > 0) .and. (m->nPos1 > 0)  && parsing loop
  820.       if m->nPos1 = 0 .and. (len(m->cOptions) > 0)
  821.          m->nPos1 = len(m->cOptions)
  822.       endif
  823.       if m->nPos1 > 0
  824.           m->cSubString = substr(m->cOptions,m->nPos1+1,;
  825.                                    len(m->cOptions)-m->nPos1)
  826.          m->nPos2 = at("~",m->cSubString)
  827.          if m->nPos2 = 0
  828.             m->nPos2 = len(m->cSubString)
  829.          else
  830.             m->nPos2 = m->nPos2 - 1
  831.          endif
  832.          m->cOptString = " "+left(m->cSubString,m->nPos2)+" "
  833.          m->nCount = m->nCount + 1
  834.          m->cPadName = "p"+ltrim(trim(str(m->nCount)))
  835.           define pad &cPadName. of mHPick prompt m->cOptString at;
  836.               m->nRow,m->nCol
  837.          m->nCol = m->nCol + len(m->cOptString)
  838.          on selection pad &cPadName. of mHPick deactivate menu
  839.          m->cOptions = m->cSubString
  840.      endif
  841.      m->nPos1 = at("~",m->cOptions)
  842.    enddo
  843.  
  844.    *-- done figure that out. On to more stuff ...
  845.    save screen to sPickList
  846.    *-- do we have a shadow?
  847.    if m->lShadow
  848.       @ m->nRow,m->nStartCol+2 fill to m->nRow+2,m->nCol+2
  849.    endif
  850.    *-- draw border
  851.    @ m->nRow-1,m->nStartCol-1 to m->nRow+1,m->nCol
  852.    *-- display 'title'
  853.    if len(m->cTitle) > 0
  854.       @ m->nRow-1,m->nStartCol+1 say m->cTitle
  855.    endif
  856.    *-- start 'er up ...
  857.    activate menu mHPick
  858.  
  859.    *-- that's it ... return screen to it's original
  860.    *-- state ...
  861.    restore screen from sPickList
  862.    release screen sPickList
  863.    
  864.    *-- deal with user keystroke/selection ...
  865.    if lastkey() = 27
  866.       m->cReturn = ""
  867.    else
  868.       m->cReturn = substr(prompt(),2,1)
  869.    endif
  870.  
  871.    *-- cleanup.
  872.    release menu mHPick
  873.    do ReColor with m->cPickColor  && reset colors
  874.  
  875.    *-- was there an existing window?
  876.    if .not. isblank(m->wPrevWind)
  877.       activate window &wPrevWind.
  878.    endif
  879.  
  880. RETURN m->cReturn
  881. *-- EoF: HPick()
  882.  
  883. *-----------------------------------------------------------------------
  884. *-- The Following Routines are in DIALOGS.PRG under slightly different 
  885. *-- names:
  886. *-- Here             DIALOGS.PRG
  887. *-- SCRNHEAD         SCRNHEAD3
  888. *-- SURROUND         SURROUND3
  889. *-- ALERT            ALERT5
  890. *-- ERRORMSG         ERRORMSG3
  891. *-- YESNO            YESNO6
  892. *-- BORD3D           BORD3D5
  893. *-- All of these have been seriously modified -- if you have been using
  894. *-- earlier versions of these routines, please read the documentation
  895. *-- below carefully!
  896. *-----------------------------------------------------------------------
  897.  
  898. FUNCTION ScrnHead
  899. *-----------------------------------------------------------------------
  900. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  901. *-- Date........: 06/09/1993
  902. *-- Notes.......: Displays a heading on the screen in a box at the top
  903. *--               of the screen. This may be in one of four types of
  904. *--               borders, giving a three-d appearance.
  905. *--               NOTE: This routine is based on the work of Miriam 
  906. *--               Liskin, and my own modifications over the years.
  907. *-- Written for.: dBASE IV, 1.5
  908. *-- Rev. History: 06/09/1993 -- Original
  909. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  910. *--               BORD3D               Procedure in PROC.PRG
  911. *-- Called by...: Any
  912. *-- Usage.......: scrnhead("<cColor>","<cText>"[,<nStyle>])
  913. *-- Examples....: cDummy = ScrnHead("rg+/gb","Print Financial Report",1)
  914. *-- Returns.....: nul/""
  915. *-- Parameters..: cColor = Colors to display box/text in
  916. *--                        Default to grey
  917. *--               cText  = text to be displayed.
  918. *--               nStyle = Type of 3-d Border (passed directly to 
  919. *--                             procedure)
  920. *--                        1 = double - raised   (Default)
  921. *--                        2 = double - recessed
  922. *--                        3 = single - raised
  923. *--                        4 = single - recessed
  924. *-----------------------------------------------------------------------
  925.  
  926.    parameters cColor,cText, nStyle
  927.    private nTextStart,cText2
  928.    
  929.    *-- if style parameter not passed, use default
  930.    if pCount() < 3 .or. (m->nStyle < 1 .or. m->nStyle > 4)
  931.       m->nStyle = 1
  932.    endif
  933.    
  934.    *-- colors
  935.    if isblank(m->cColor)
  936.       m->cColor = "n/w"
  937.    endif
  938.    
  939.    m->cText2 = " "+trim(m->cText)+" "     && ad spaces to left and right
  940.    m->nTextStart = (81-len(trim(m->cText2)))/2    && centered text 
  941.    activate screen
  942.    m->nTop    = iif(m->nStyle < 3,0,1)
  943.    m->nLeft   = m->nTextStart - iif(m->nStyle<3,3,2) && back up 3 (or 2)
  944.    m->nBottom = iif(m->nStyle < 3,4,3)               && bottom row
  945.    m->nRight  = (81-m->nTextStart) + iif(m->nStyle<3,3,2) 
  946.    
  947.    *-- draw shadow
  948.    do shadow with m->nTop,m->nLeft,m->nBottom,m->nRight
  949.    
  950.    *-- fill in box
  951.    @m->nTop,m->nLeft fill to m->nBottom,m->nRight color &cColor.
  952.    
  953.    *-- place border on top of it all
  954.    do bord3d with m->nTop,m->nLeft,m->nBottom,m->nRight,m->cColor,;
  955.                   m->nStyle
  956.    
  957.    *-- finally, let's display the text ...
  958.    @2, m->nTextStart say m->cText2 color &cColor. 
  959.  
  960. RETURN ""
  961. *-- EoF: ScrnHead()
  962.  
  963. FUNCTION Surround
  964. *-----------------------------------------------------------------------
  965. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  966. *-- Date........: 06/28/1993
  967. *-- Notes.......: Displays a message surrounded by a box anywhere on 
  968. *--               the screen -- this version centers automatically on
  969. *--               the screen and gives a 3-D border ...
  970. *--               This is based on the original routine by Miriam Liskin
  971. *-- Written for.: dBASE IV, 1.5
  972. *-- Rev. History: 06/09/1993 -- Original
  973. *--               06/28/1993 -- Fixed minor problem -- if displaying
  974. *--                             over a textured background, the borders
  975. *--                             can look a bit odd. Added a CLEAR ...
  976. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  977. *--               Bord3D               Procedure in PROC.PRG
  978. *-- Called by...: Any
  979. *-- Usage.......: Surround(<nLine>,"<cColor>","<cText>"[,<nStyle>])
  980. *-- Example.....: cDummy = Surround(5,12,"RG+/GB",;
  981. *--                        "Processing ... Do not Touch!",1)
  982. *-- Returns.....: Nul/""
  983. *-- Parameters..: nLine   = Line to display "surrounded" message at
  984. *--                         if nLine = 0, we will center on the screen
  985. *--                         vertically, as well as horizontally.
  986. *--               cColor  = Color variable/colors (Default to grey)
  987. *--               cText   = Text to be displayed inside box
  988. *--               nStyle  = Style of border 1 = Double - Raised(Default)
  989. *--                                         2 = Double - Recessed
  990. *--                                         3 = Single - Raised
  991. *--                                         4 = Double - Recessed
  992. *--                          NOTE: This is OPTIONAL
  993. *-----------------------------------------------------------------------
  994.    
  995.    parameters nLine,cColor,cText,nStyle
  996.    private nStyle, cColor, cText2, nTextStart, nTop, nLeft, nBottom,;
  997.           nRight, nLine
  998.    
  999.    *-- deal with defaults
  1000.    if pCount() < 4 .or. (m->nStyle < 1 .or. m->nStyle > 4) 
  1001.       m->nStyle = 1
  1002.    endif
  1003.    if isblank(m->cColor)
  1004.       m->cColor = "n/w"
  1005.    endif
  1006.    
  1007.    *-- deal with nLine being equal to 0 when user passes this (this will
  1008.    *-- cause the routine to center on the screen ... no matter how the
  1009.    *-- screen is set).
  1010.    if m->nLine = 0
  1011.       m->cScreen = set("DISPLAY")
  1012.       if m->cScreen = "MONO"
  1013.          m->nScreen = 24
  1014.       else
  1015.          m->nScreen = val(right(m->cScreen,2)) - 1  && EGA25 = 0 to 24
  1016.       endif
  1017.       m->nLine = int(m->nScreen/2)  && halfway ...
  1018.    endif
  1019.    
  1020.    m->cText2 = " "+trim(m->cText)+" "    && add spaces to left and right
  1021.    m->nTextStart = (81-len(trim(m->cText2)))/2  && centered text 
  1022.    activate screen
  1023.    m->nTop    = m->nLine - iif(m->nStyle < 3,2,1)      && up 2 or 1 ...
  1024.    m->nLeft   = m->nTextStart - iif(m->nStyle < 3,3,2) && back up 3 
  1025.    m->nBottom = m->nLine + iif(m->nStyle < 3,2,1)      && bottom row
  1026.    m->nRight  = (81-m->nTextStart) + iif(m->nStyle < 3,3,2) && right 
  1027.    
  1028.    *-- draw shadow
  1029.    do shadow with m->nTop,m->nLeft,m->nBottom,m->nRight
  1030.    
  1031.    *-- fill in box
  1032.    @m->nTop,m->nLeft clear to m->nBottom,m->nRight 
  1033.    @m->nTop,m->nLeft fill  to m->nBottom,m->nRight color &cColor.
  1034.    
  1035.    *-- place border on top of it
  1036.    do Bord3D with m->nTop,m->nLeft,m->nBottom,m->nRight,m->cColor,;
  1037.                   m->nStyle
  1038.    
  1039.    *-- finally, let's display the text ...
  1040.    @m->nLine, m->nTextStart say m->cText2 color &cColor.  
  1041.    
  1042. RETURN "" 
  1043. *-- EoF: Surround()
  1044.  
  1045. FUNCTION Alert
  1046. *-----------------------------------------------------------------------
  1047. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  1048. *-- Date........: 06/11/1993
  1049. *-- Notes.......: This is a general purpose "ALERT" dialog box. It is
  1050. *--               based heavily on the original work by Adam L. Menkes
  1051. *--               (Borland Technical Support), and Joey D. Carrol, as 
  1052. *--               well as various tinkerings I have done in previous 
  1053. *--               versions. This routine creates a popup on the screen 
  1054. *--               with a title and one line message (wrapped if needed),
  1055. *--               forcing the user to notice the message.
  1056. *--               The user must use the mouse on the 'OK' pad, press 
  1057. *--               <Esc> or press <Enter> to move on in the program that 
  1058. *--               called this function.
  1059. *-- Written for.: dBASE IV, 1.5
  1060. *-- Rev. History: 06/19/1992 -- Adam L. Menkes -- Original "Alert()" 
  1061. *--                 routine.
  1062. *--               06/11/1993 -- Kenneth J. Mayer -- complete overhaul.
  1063. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  1064. *--               JUSTIFY()            Function in PROC.PRG
  1065. *--               COLORBRK()           Function in PROC.PRG
  1066. *--               FBCLRBRK()           Function in PROC.PRG 
  1067. *--               BORD3D               Procedure in PROC.PRG
  1068. *-- Called by...: Any
  1069. *-- Usage.......: Alert("<cTitle>","<cMessage>","<cColor>"[,<nStyle>])
  1070. *-- Example.....: lX = Alert("Print Aborted","You pressed <ESC>",;
  1071. *--                           "rg+/r,w+/b,rg+/r",2)
  1072. *-- Returns.....: Logical
  1073. *-- Parameters..: cTitle   = Title line
  1074. *--               cMessage = One line message (up to 254 characters)
  1075. *--               cColor   = Colors: <window forg/back>,<pad> (and 
  1076. *--                                  title),<box>
  1077. *--                          Default is to "steel" grey
  1078. *--               nStyle   = OPTIONAL: 1 = double raised border(default)
  1079. *--                                    2 = double recessed bord
  1080. *--                                    3 = single raised
  1081. *--                                    4 = single recessed
  1082. *-----------------------------------------------------------------------
  1083.  
  1084.    parameters cTitle, cMessage, cColor, nStyle
  1085.    private wWindow,mPad,cTempCol,cColorF,cColorB,cColorAll
  1086.    private nWidth,nTop,nLeft,nBottom,nRight,cTitle2,cMessage2
  1087.  
  1088.    *-- don't jamb against walls
  1089.    m->cTitle2 = " " + ltrim(trim(m->cTitle)) + " " 
  1090.    m->cMessage2 = " " + ltrim(trim(m->cMessage)) + " " 
  1091.    wWindow = WINDOW()                             && save current Window
  1092.    save screen to sTemp                           && save the screen
  1093.    activate screen
  1094.    cDummykey = inkey()                      && clear out keyboard buffer
  1095.  
  1096.    *-- deal with defaults
  1097.    if pCount() < 4 .or. (m->nStyle < 1 .or. m->nStyle > 4)
  1098.       m->nStyle = 1
  1099.    endif
  1100.    if pCount() < 3             && no colors? default to grey
  1101.       m->cColor = "n/w,w+/n,n/w"
  1102.    endif
  1103.    if isblank(m->cColor) 
  1104.       m->cColor = "n/w,w+/n,n/w"
  1105.    endif
  1106.    
  1107.    *-- determine coordinates -- we're basing some of this on YESNO()
  1108.    *-- routines -- alert box will be only so wide ...
  1109.    m->nWidth = 36 + iif(m->nStyle<3,4,2) 
  1110.    
  1111.    *-- height will be based on how many lines of message we have
  1112.    m->nHeight = int(len(m->cMessage)/m->nWidth) +;
  1113.              iif(mod(len(m->cMessage),m->nWidth) > 0,1,0) +;
  1114.              iif(m->nStyle < 3,3,1) + 6
  1115.    
  1116.    *-- now we have height and width,let's determine where to center this
  1117.    *-- first, we need screen height
  1118.    m->cScreen = set("DISPLAY")
  1119.    if m->cScreen = "MONO"
  1120.       m->nScreen = 24
  1121.    else
  1122.       m->nScreen = val(right(m->cScreen,2)) - 1  && (EGA25 = 0 to 24)
  1123.    endif
  1124.    
  1125.    *-- now to determine coordinates
  1126.    m->nTop     = (m->nScreen - m->nHeight) / 2
  1127.    m->nBottom  = m->nTop + m->nHeight
  1128.    m->nLeft    = 20
  1129.    m->nRight   = m->nLeft + m->nWidth
  1130.    
  1131.    *-- define window (with no border so we can place the 3-D one on it)
  1132.    Define window wAlert from m->nTop,m->nLeft to m->nBottom,m->nRight ;
  1133.                   NONE color &cColor.
  1134.  
  1135.    *-- display shadow
  1136.    do shadow with m->nTop,m->nLeft,m->nBottom,m->nRight
  1137.  
  1138.    *-- start 'er up ...
  1139.    activate window wAlert
  1140.  
  1141.    *-- put 3-D Border in there
  1142.    m->cBordCol = colorbrk(m->cColor,1)
  1143.    do BORD3D with 0,0,(m->nBottom-m->nTop),m->nWidth,m->cBordCol,;
  1144.                        m->nStyle
  1145.  
  1146.    *-- display a new type title line to look more like Windows(TM)
  1147.    if len(m->cTitle) < m->nWidth
  1148.       m->cTitle = justify(m->cTitle,35,"C")
  1149.       if len(m->cTitle) < 35
  1150.          m->cTitle = m->cTitle + " "
  1151.      endif
  1152.    endif
  1153.     m->cTempCol = colorbrk(m->cColor,2)      
  1154.     *-- Background of title bar text
  1155.     m->cColorF   = FBClrBrk("B",m->cTempCol)  
  1156.     *-- Foreground of 'normal' text
  1157.     m->cColorB   = FBClrBrk("B",colorbrk(m->cColor,1)) 
  1158.     *-- color of 'Special' line
  1159.    m->cColorAll = m->cColorF + "/" + m->cColorB
  1160.    m->nRow = iif(m->nStyle<3,2,1)
  1161.    m->nCol = iif(m->nStyle<3,3,2)
  1162.    @m->nRow,  m->nCol say m->cTitle color &cTempCol. && the Title Bar
  1163.    @m->nRow+1,m->nCol say replicate(chr(223),35) color &cColorAll.  
  1164.  
  1165.    *-- display message
  1166.    do WordWrap with iif(m->nStyle<3,4,3),iif(m->nStyle<3,4,3),;
  1167.                      m->cMessage,34
  1168.  
  1169.    *-- define/display a very small menu (one pad)
  1170.    define menu mAlert
  1171.    m->nButtonRow = m->nHeight - iif(m->nStyle<3,3,2)
  1172.    m->nButtonCol = m->nWidth/2 - 1
  1173.    define pad pPad1 of mAlert prompt "[OK]" at m->nButtonRow,;
  1174.                                                m->nButtonCol
  1175.    on selection pad pPad1 of mAlert deactivate menu
  1176.  
  1177.    *-- deal with <Enter>
  1178.    on key label ctrl-M keyboard "{27}"
  1179.  
  1180.    *-- before starting, put a border around the button
  1181.    do bord3d with m->nButtonRow-1,m->nButtonCol-1,m->nButtonRow+1,;
  1182.                   m->nButtonCol+4,m->cBordCol,3
  1183.  
  1184.    *-- start it up
  1185.    activate menu mAlert
  1186.  
  1187.    *-- deal with user 'input'
  1188.    m->mPad = pad()
  1189.    deactivate window wAlert
  1190.    release window wAlert
  1191.  
  1192.    *-- restore environment, free up RAM by releasing things
  1193.    on key label ctrl-m
  1194.    restore screen from sTemp
  1195.    release screen sTemp
  1196.    release menu mAlert
  1197.    if "" # wWindow
  1198.        activate window &wWindow.
  1199.    endif
  1200.    
  1201. RETURN .not. "" = m->mPad  && not empty pad?
  1202. *-- EoF: Alert()
  1203.  
  1204. FUNCTION ErrorMsg
  1205. *-----------------------------------------------------------------------
  1206. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  1207. *-- Date........: 06/11/1993
  1208. *-- Notes.......: Display an error message in a Window: 
  1209. *--                           ** ERROR [#] **
  1210. *--
  1211. *--                       Message (wraps in window)
  1212. *--
  1213. *--                                 [OK]               
  1214. *--
  1215. *-- Written for.: dBASE IV, 1.5
  1216. *-- Rev. History: 06/08/1992 -- Original
  1217. *--               03/18/1993 -- Modified to give the three-d border ...
  1218. *--               06/10/1993 -- Modified to give 4 options to border,
  1219. *--                             default color of grey/black/white,
  1220. *--                             handle single message of up to 254 
  1221. *--                             characters.
  1222. *-- Calls.......: SHADOW               Procedure in PROC.PRG
  1223. *--               CENTER               Procedure in PROC.PRG
  1224. *--               ALLTRIM()            Function in PROC.PRG
  1225. *--               WORDWRAP             Procedure in PROC.PRG
  1226. *--               BORD3D               Procedure in PROC.PRG
  1227. *-- Called by...: Any
  1228. *-- Usage.......: ErrorMsg(<cErr>,<cMess>[,<cColor>[,<nStyle>]])
  1229. *-- Example.....: cDummy = errormsg("3","This record already exists!",;
  1230. *--                   "rg+/r,rg+/r,rg+/r",2)
  1231. *-- Returns.....: numeric value of keystroke user presses (cUser)
  1232. *-- Parameters..: cErr   = Error # (can be blank, but use "" for blank)
  1233. *--               cMess  = Error message -- up to 254 characters
  1234. *--               cColor = Colors for text/window/border (default=grey)
  1235. *--               nStyle = 1 = Double - Raised
  1236. *--                        2 = Double - Recessed
  1237. *--                        3 = Single - Raised
  1238. *--                        4 = Single - Recessed
  1239. *-----------------------------------------------------------------------
  1240.    
  1241.    parameters cErr,cMess,cColor,nStyle
  1242.    private cCursor,cUser,cCurColor,cTempCol
  1243.    
  1244.    *-- defaults
  1245.    if pCount() < 4 .or. (m->nStyle < 1 .or. m->nStyle > 4)
  1246.       m->nStyle = 1
  1247.    endif
  1248.    if pCount() < 3
  1249.       m->cColor = "n/w,w+/n,n/w"
  1250.    endif
  1251.    if isblank(m->cColor)
  1252.       m->cColor = "n/w,w+/n,n/w"
  1253.    endif
  1254.    
  1255.    *-- screen stuff
  1256.    save screen to sErr
  1257.    m->cWindow = window()
  1258.    activate screen
  1259.    
  1260.    *-- determine coordinates
  1261.    *-- width is a default of 36 characters, plus border ...
  1262.    m->nWidth = 36 + iif(m->nStyle < 3, 4, 2)  && based on border style
  1263.    
  1264.    *-- height is based on lines in message
  1265.    m->nHeight = int(len(cMess)/m->nWidth) +;
  1266.                 iif( mod( len(cMess), m->nWidth) > 0,1,0) +;
  1267.                 iif(m->nStyle < 3,3,1) + 6
  1268.    
  1269.    *-- now we have height and width, let's determine how to center this
  1270.    *-- puppy on the screen
  1271.    m->cScreen = set("DISPLAY")
  1272.    if m->cScreen = "MONO"
  1273.       m->nScreen = 24
  1274.    else
  1275.       m->nScreen = val(right(m->cScreen,2)) - 1
  1276.    endif
  1277.    
  1278.    *-- coordinates
  1279.    m->nTop    = (m->nScreen-m->nHeight) / 2
  1280.    m->nBottom = m->nTop + m->nHeight
  1281.    m->nLeft   = 20
  1282.    m->nRight  = m->nLeft + m->nWidth
  1283.    
  1284.    *-- define the window
  1285.    define window wErr from m->nTop,m->nLeft to m->nBottom,m->nRight ;
  1286.                       NONE color &cColor.
  1287.    do shadow with m->nTop,m->nLeft,m->nBottom,m->nRight
  1288.    activate window wErr
  1289.    
  1290.    *-- do border
  1291.    m->cBordCol = colorbrk(m->cColor,1)
  1292.    do bord3d with 0,0,(m->nBottom-m->nTop),m->nWidth,m->cBordCol,;
  1293.                        m->nStyle
  1294.    
  1295.    m->cCursor = set("CURSOR")
  1296.    set cursor off
  1297.    
  1298.    *-- deal with "title" line
  1299.    if len(trim(m->cErr)) > 0  && if there's an error number ...
  1300.       m->cTitle = "** ERROR "+alltrim(m->cErr)+" **"
  1301.    else                      && otherwise, don't display errornumber
  1302.       m->cTitle = "** ERROR **"
  1303.    endif
  1304.    m->cTitle = justify(m->cTitle,35,"C")
  1305.    if len(m->cTitle) < 35
  1306.       m->cTitle = m->cTitle + " "
  1307.    endif
  1308.    m->cTempCol = colorbrk(m->cColor,2)
  1309.    m->cColorF  = fbclrbrk("B",m->cTempCol)
  1310.    m->cColorB  = fbclrbrk("B",colorbrk(m->cColor,1))
  1311.    m->cColorAll = m->cColorF+"/"+m->cColorB
  1312.    m->nRow = iif(m->nStyle<3,2,1)
  1313.    m->nCol = iif(m->nStyle<3,3,2)
  1314.    @m->nRow,m->nCol say m->cTitle color &cTempCol.
  1315.    @m->nRow+1,m->nCol say replicate(chr(223),35) color &cColorAll.
  1316.    
  1317.    *-- display message
  1318.    do wordwrap with iif(m->nStyle<3,4,3),iif(m->nStyle<3,4,3),cMess,34
  1319.    
  1320.    *-- define menu ...
  1321.    define menu mError
  1322.    m->nButtonRow = m->nHeight - iif(m->nStyle<3,3,2)
  1323.    m->nButtonCol = m->nWidth/2 - 1
  1324.    define pad pPad1 of mError prompt "[OK]" at m->nButtonRow,;
  1325.                                                m->nButtonCol
  1326.    on selection pad pPad1 of mError deactivate menu
  1327.    on key label ctrl-M keyboard "{27}"
  1328.    do bord3d with m->nButtonRow-1,m->nButtonCol-1,m->nButtonRow+1,;
  1329.                   m->nButtonCol+4,m->cBordCol,3
  1330.    
  1331.    *-- start menu
  1332.    activate menu mError
  1333.    
  1334.    *-- deal with user 'input'
  1335.    m->mPad = pad()
  1336.    
  1337.    *-- reset and cleanup
  1338.    set cursor &cCursor.
  1339.    release window wErr
  1340.    restore screen from sErr
  1341.    release screen sErr
  1342.    release menu mError
  1343.    on key label ctrl-M
  1344.    if "" # m->cWindow
  1345.       activate window &cWindow.
  1346.    endif
  1347.    
  1348. RETURN .not. "" = m->mPad  && empty pad?
  1349. *-- EoF: ErrorMsg()
  1350.  
  1351. FUNCTION YesNo
  1352. *-----------------------------------------------------------------------
  1353. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  1354. *-- Date........: 06/11/1993
  1355. *-- Notes.......: This is a combination of the "best" of YESNO4() and
  1356. *--               YESNO5() (I hope). The work involved is based on work
  1357. *--               by Miriam Liskin, Martin Leon, Clinton Warren,
  1358. *--               Joey D. Carol, and myself. 
  1359. *--               This Yes/No dialog box should do the following:
  1360. *--               A) Full 3-D effect(s)
  1361. *--               B) Color options up to programmer/user
  1362. *--               C) YES/NO buttons at bottom of dialog box
  1363. *--               D) Allow for location on screen
  1364. *--               E) Allow for up to 256 characters of text in message
  1365. *--               F) Give a "windows" like title bar
  1366. *--               G) Allow for screens bigger'n 25 lines ... (EGA43, 
  1367. *--                  VGA50 ...)
  1368. *-- Written for.: dBASE IV, 1.5 or later
  1369. *-- Rev. History: 06/11/1993 -- Original
  1370. *-- Calls.......: Shadow             Procedure in PROC.PRG
  1371. *--               Center             Procedure in PROC.PRG
  1372. *--               Bord3D             Procedure in PROC.PRG
  1373. *--               WordWrap           Procedure in PROC.PRG
  1374. *--               ColorBrk()         Function in PROC.PRG
  1375. *--               FBClrBrk()         Function in PROC.PRG
  1376. *--               Justify()          Function in PROC.PRG
  1377. *-- Called by...: Any
  1378. *-- Usage.......: x=YesNo(<lDefault>,<cWhere>,<cTitle>,<cMessage>,;
  1379. *--                       <cColor>,<nStyle>)
  1380. *-- Example.....: if YesNo(.t.,"CC","Delete Record?",;
  1381. *--                        "If you select [Yes] "+;
  1382. *--                         "you will delete this record.",cWind1,3)
  1383. *-- Returns.....: logical 
  1384. *-- Parameters..: lDefault = Which menu pad do you wish to default to?
  1385. *--                          .T. = "Yes", .F. = "No"
  1386. *--               cWhere   = Where on the screen do you wish the dialog 
  1387. *--                          box to appear?
  1388. *--                          UL = Upper Left
  1389. *--                          UC = Upper Center
  1390. *--                          UR = Upper Right
  1391. *--                          CL = Center Left
  1392. *--                          CC = Center Center (default)
  1393. *--                          CR = Center Right
  1394. *--                          BL = Bottom Left
  1395. *--                          BC = Bottom Center
  1396. *--                          BR = Bottom Right
  1397. *--               cTitle   = Title for the title bar, up to 30 chars
  1398. *--               cMessage = Message, up to 254 characters
  1399. *--               cColor   = Colors in standard foreground/background.
  1400. *--                          If no colors given, you will get the 
  1401. *--                          Borland "steel grey", with black text. 
  1402. *--                          The buttons and title bar will end up 
  1403. *--                          bright white on black.
  1404. *--               nStyle   = Border Style
  1405. *--                          1 = Double Border, raised (default)
  1406. *--                          2 = Double Border, recessed
  1407. *--                          3 = Single Border, raised
  1408. *--                          4 = Single Border, recessed
  1409. *-----------------------------------------------------------------------
  1410.  
  1411.    parameters lDefault, cWhere, cTitle, cMessage, cColor, nStyle
  1412.    private nParm,nWidth,nHeight,cRow,cCol,nTop,nBottom,nLeft,nRight
  1413.    private cTempCol
  1414.    private nBordCol,nButtonRow,cWindow,cScreen,nScreen
  1415.    
  1416.    *-- save current screen, save current window
  1417.    m->cWindow = window()
  1418.    save screen to sYesNo
  1419.    
  1420.    *-- determine # of parameters passed, and set defaults if necessary
  1421.    nParm = pcount()
  1422.    if nParm < 6            && no selection for border-style, set to def.
  1423.       m->nStyle = 1
  1424.    endif
  1425.    if m->nStyle < 1 .or. m->nStyle > 4 && don't screw with _my_ routine!
  1426.       m->nStyle = 1
  1427.    endif
  1428.    if nParm < 5                   && no colors, set to steel-grey
  1429.       m->cColor = "N/W,W+/N,N/W"
  1430.    endif
  1431.    if isblank(m->cColor)
  1432.       m->cColor = "N/W,W+/N,N/W"
  1433.    endif
  1434.    if isblank(cWhere)            && default location is center of screen
  1435.       m->cWhere = "CC"
  1436.    endif
  1437.    
  1438.    *-- set some defaults
  1439.    m->nWidth = 36 + iif(m->nStyle < 3,4,2)    && width of dialog box
  1440.    
  1441.    *-- determine height of window by text
  1442.    *-- if the remainder of the length of the message/width is > 0
  1443.    *--   we have one more line of text, add 1, else add 0
  1444.    *-- border will determine more ... (if it's 1 or 2, it's double-size,
  1445.    *--   so we add 4 lines (top/bottom * 2), if it's 3 or 4,it's single)
  1446.    *-- add 2 rows for the title, and 3 for the menu, and 1 for the 
  1447.    *-- button borders ...
  1448.    m->nHeight = int(len(m->cMessage)/m->nWidth) + ;
  1449.              iif(mod(len(m->cMessage),m->nWidth) > 0,1,0) +;
  1450.              iif(m->nStyle < 3,3,1) +;
  1451.              6
  1452.    
  1453.    *-- now to determine window Coordinates
  1454.    m->cRow = left(m->cWhere,1)
  1455.    m->cCol = right(m->cWhere,1)
  1456.    
  1457.    *-- get screen height
  1458.    m->cScreen = SET("DISPLAY")
  1459.    if m->cScreen = "MONO"
  1460.       m->nScreen = 24
  1461.    else
  1462.       m->nScreen = val(right(m->cScreen,2)) - 1  && (EGA25 = 0 to 24)
  1463.    endif
  1464.    
  1465.    *-- this is where we _really_ determine the coordinates
  1466.    do case   && first let's get the rows (top/bottom)
  1467.       case m->cRow = "U"
  1468.          m->nTop = 1
  1469.       case m->cRow ="B"
  1470.          m->nTop = (m->nScreen - m->nHeight - 2) &&leave room for shadow
  1471.       otherwise  && "C" or center ...
  1472.          m->nTop = (m->nScreen - m->nHeight) / 2
  1473.    endcase
  1474.    m->nBottom = m->nTop + m->nHeight
  1475.    
  1476.    do case   && now for the columns
  1477.       case m->cCol = "L"
  1478.          m->nLeft = 5
  1479.       case m->cCol = "R"
  1480.          m->nLeft = 35
  1481.       otherwise && "C" or center
  1482.          m->nLeft = 20
  1483.    endcase
  1484.    m->nRight = m->nLeft + m->nWidth
  1485.    
  1486.    *-- define window
  1487.    activate screen
  1488.    define window wYesNo from m->nTop,m->nLeft to m->nBottom,m->nRight;
  1489.                            NONE color &cColor.
  1490.    
  1491.    *-- define menu
  1492.    define menu mYesNo
  1493.    m->nButtonRow = m->nHeight - iif(m->nStyle<3,3,2)
  1494.    define pad pYes of mYesNo prompt "[Yes]" at m->nButtonRow,10
  1495.    define pad pNo  of mYesNo prompt "[No]"  at m->nButtonRow,25
  1496.    on selection pad pYes of mYesNo deactivate menu
  1497.    on selection pad pNo  of mYesNo deactivate menu
  1498.    
  1499.    *-- activate window
  1500.    do shadow with m->nTop,m->nLeft,m->nBottom,m->nRight
  1501.    activate window wYesNo
  1502.    
  1503.    *-- draw border
  1504.    m->cBordCol = left(m->cColor,at(",",m->cColor)-1)
  1505.    do bord3d with 0,0,m->nHeight,m->nWidth,m->cBordCol,m->nStyle 
  1506.    
  1507.    *-- display title
  1508.    if len(m->cTitle) < m->nWidth
  1509.       m->cTitle = justify(m->cTitle,35,"C")
  1510.       if len(m->cTitle) < 35
  1511.          m->cTitle = m->cTitle + " "
  1512.       endif
  1513.    endif
  1514.    m->cTempCol = colorbrk(m->cColor,2)
  1515.    m->cColorF  = FBClrBrk("B",m->cTempCol)
  1516.    m->cColorB  = FBClrBrk("B",colorbrk(m->cColor,1))
  1517.    m->cColorAll= m->cColorF+"/"+m->cColorB
  1518.    m->nRow = iif(m->nStyle < 3,2,1)
  1519.    m->nCol = iif(m->nStyle < 3,3,2)
  1520.    @m->nRow,  m->nCol say m->cTitle color &cTempCol.
  1521.    @m->nRow+1,m->nCol say replicate(chr(223),35) color &cColorAll.
  1522.    
  1523.    *-- display text
  1524.    do WordWrap with iif(m->nStyle<3,4,3),iif(m->nStyle<3,4,3),;
  1525.                         m->cMessage,34
  1526.    
  1527.    *-- set Y/N keys for menu pad
  1528.    clear typeahead && just to be safe
  1529.    on key label Y keyboard iif(pad() = "PYES","",chr(19))+chr(13)
  1530.    on key label N keyboard iif(pad() = "PNO" ,"",chr(4) )+chr(13)
  1531.    
  1532.    *-- deal with borders around the pads ...
  1533.    do bord3d with m->nButtonRow-1, 9,m->nButtonRow+1,15,m->cBordCol,3
  1534.    do bord3d with m->nButtonRow-1,24,m->nButtonRow+1,29,m->cBordCol,3
  1535.    
  1536.    *-- activate menu
  1537.    if lDefault
  1538.       activate menu mYesNo pad pYes
  1539.    else
  1540.       activate menu mYesNo pad pNo
  1541.    endif
  1542.    
  1543.    *-- cleanup
  1544.    on key label Y
  1545.    on key label N
  1546.    release window wYesNo
  1547.    restore screen from sYesNo
  1548.    release screen sYesNo
  1549.    release menu mYesNo
  1550.    if .not. isblank(m->cWindow)
  1551.       activate window &cWindow.
  1552.    endif
  1553.    
  1554. RETURN iif(pad() = "PYES",.T.,.F.)
  1555. *-- EoF: YesNo()
  1556.  
  1557. PROCEDURE Bord3D
  1558. *-----------------------------------------------------------------------
  1559. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  1560. *-- Date........: 06/02/1993
  1561. *-- Notes.......: This is an attempt to combine the 3-D border routines
  1562. *--               (BORD3D through BORD3D4) -- allowing a selection 
  1563. *--               between four border styles ... 
  1564. *-- Written for.: dBASE IV, 1.5 or later
  1565. *-- Rev. History: 06/02/1993
  1566. *-- Calls.......: BackColor()          Function in PROC.PRG
  1567. *-- Called by...: Any 
  1568. *-- Usage.......: do Bord3D with <nULR>,<nULC>,<nBRR>,<nBRC>,<cColor>,;
  1569. *--                              <nStyle>
  1570. *-- Example.....: do Bord3D with 0,0,15,60,2
  1571. *-- Returns.....: None
  1572. *-- Parameters..: nULR   = Upper Left Row (Starting Coordinates)
  1573. *--               nULC   = Upper Left Column
  1574. *--               nBRR   = Bottom Right Row (Ending Coordinates)
  1575. *--               nBRC   = Bottom Right Column
  1576. *--               cColor = Colors of Window/Box ...
  1577. *--               nStyle = Border style:
  1578. *--                        1 = Double, Raised
  1579. *--                        2 = Double, Recessed
  1580. *--                        3 = Single, Raised
  1581. *--                        4 = Single, Recessed
  1582. *-----------------------------------------------------------------------
  1583.  
  1584.    parameters nULR, nULC, nBRR, nBRC, cColor, nStyle
  1585.    private cBorder,cBackColor,cHighColor,cShadColor
  1586.    
  1587.    *-- deal with border ...
  1588.    m->cBorder = set("BORDER")
  1589.    set border to single
  1590.    
  1591.    *-- figure out colors
  1592.    m->cBackColor = backcolor(m->cColor)
  1593.    m->cHighColor = "W+/"+m->cBackColor
  1594.    m->cShadColor = "N/"+m->cBackColor
  1595.    
  1596.    if m->nStyle < 1 .or. m->nStyle > 4  && if not 1 through 4 ...
  1597.       m->nStyle = 1
  1598.    endif
  1599.    
  1600.    do case
  1601.       case m->nStyle = 1
  1602.       
  1603.          *-- Raised DOUBLE Border
  1604.          *-- Outside of "border"
  1605.          @m->nULR,m->nULC to m->nULR,m->nBRC   color &cHighColor. 
  1606.          @m->nULR,m->nULC to m->nBRR,m->nULC   color &cHighColor.   
  1607.          @m->nULR,m->nULC say chr(218)         color &cHighColor. 
  1608.          @m->nBRR,m->nULC say chr(192)         color &cHighColor. 
  1609.          @m->nULR,m->nBRC to m->nBRR,m->nBRC   color &cShadColor. 
  1610.          @m->nBRR,m->nULC+1 to m->nBRR,m->nBRC color &cShadColor. 
  1611.          @m->nULR,m->nBRC say chr(191)         color &cShadColor. 
  1612.          @m->nBRR,m->nBRC say chr(217)         color &cShadColor. 
  1613.       
  1614.          *-- inside of "border"
  1615.          @m->nULR+1,m->nULC+2 to m->nULR+1,m->nBRC-2 color &cShadColor. 
  1616.          @m->nULR+1,m->nULC+2 to m->nBRR-1,m->nULC+2 color &cShadColor.  
  1617.          @m->nULR+1,m->nULC+2 say chr(218)           color &cShadColor. 
  1618.          @m->nBRR-1,m->nULC+2 say chr(192)           color &cShadColor. 
  1619.          @m->nULR+1,m->nBRC-2 to m->nBRR-1,m->nBRC-2 color &cHighColor. 
  1620.          @m->nBRR-1,m->nULC+3 to m->nBRR-1,m->nBRC-2 color &cHighColor. 
  1621.          @m->nULR+1,m->nBRC-2 say chr(191)           color &cHighColor. 
  1622.          @m->nBRR-1,m->nBRC-2 say chr(217)           color &cHighColor. 
  1623.    
  1624.       case m->nStyle = 2
  1625.          
  1626.          *-- Recessed DOUBLE Border
  1627.          *-- Outside of "border"
  1628.          @m->nULR,m->nULC to m->nULR,m->nBRC   color &cShadColor. 
  1629.          @m->nULR,m->nULC to m->nBRR,m->nULC   color &cShadColor.   
  1630.          @m->nULR,m->nULC say chr(218)         color &cShadColor. 
  1631.          @m->nBRR,m->nULC say chr(192)         color &cShadColor. 
  1632.          @m->nULR,m->nBRC to m->nBRR,m->nBRC   color &cHighColor. 
  1633.          @m->nBRR,m->nULC+1 to m->nBRR,m->nBRC color &cHighColor. 
  1634.          @m->nULR,m->nBRC say chr(191)         color &cHighColor. 
  1635.          @m->nBRR,m->nBRC say chr(217)         color &cHighColor. 
  1636.       
  1637.          *-- inside of "border"
  1638.          @m->nULR+1,m->nULC+2 to m->nULR+1,m->nBRC-2 color &cHighColor.
  1639.          @m->nULR+1,m->nULC+2 to m->nBRR-1,m->nULC+2 color &cHighColor.   
  1640.          @m->nULR+1,m->nULC+2 say chr(218)           color &cHighColor. 
  1641.          @m->nBRR-1,m->nULC+2 say chr(192)           color &cHighColor. 
  1642.          @m->nULR+1,m->nBRC-2 to m->nBRR-1,m->nBRC-2 color &cShadColor. 
  1643.          @m->nBRR-1,m->nULC+3 to m->nBRR-1,m->nBRC-2 color &cShadColor. 
  1644.          @m->nULR+1,m->nBRC-2 say chr(191)           color &cShadColor. 
  1645.          @m->nBRR-1,m->nBRC-2 say chr(217)           color &cShadColor. 
  1646.    
  1647.       case m->nStyle = 3
  1648.          
  1649.          *-- Raised SINGLE Border
  1650.          @m->nULR,m->nULC to m->nULR,m->nBRC color &cHighColor. 
  1651.          @m->nULR,m->nULC to m->nBRR,m->nULC color &cHighColor. 
  1652.          @m->nULR,m->nBRC to m->nBRR,m->nBRC color &cShadColor. 
  1653.          @m->nBRR,m->nULC to m->nBRR,m->nBRC color &cShadColor. 
  1654.          @m->nULR,m->nULC say chr(218)       color &cHighColor. 
  1655.          @m->nBRR,m->nULC say chr(192)       color &cHighColor. 
  1656.          @m->nULR,m->nBRC say chr(191)       color &cShadColor. 
  1657.          @m->nBRR,m->nBRC say chr(217)       color &cShadColor. 
  1658.          
  1659.       case m->nStyle = 4
  1660.    
  1661.          *-- Recessed SINGLE Border
  1662.          @m->nULR,m->nULC to m->nULR,m->nBRC color &cShadColor. 
  1663.          @m->nULR,m->nULC to m->nBRR,m->nULC color &cShadColor.   
  1664.          @m->nULR,m->nBRC to m->nBRR,m->nBRC color &cHighColor. 
  1665.          @m->nBRR,m->nULC to m->nBRR,m->nBRC color &cHighColor. 
  1666.          @m->nULR,m->nULC say chr(218) color       &cShadColor. 
  1667.          @m->nBRR,m->nULC say chr(192) color       &cShadColor. 
  1668.          @m->nULR,m->nBRC say chr(191) color       &cHighColor. 
  1669.          @m->nBRR,m->nBRC say chr(217) color       &cHighColor. 
  1670.    
  1671.    endcase
  1672.    
  1673.    *-- reset border
  1674.    set border to &cBorder.
  1675.    
  1676. RETURN
  1677. *-- EoP: Bord3D
  1678.  
  1679. FUNCTION YNC
  1680. *-----------------------------------------------------------------------
  1681. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  1682. *-- Date........: 06/24/1993
  1683. *-- Notes.......: This is a variation of YESNO(), designed to allow the
  1684. *--               programmer to give the user three buttons, instead of
  1685. *--               two -- "Yes", "No" and "Cancel". The one MAJOR 
  1686. *--               difference is the logical parameter "lDefault" must 
  1687. *--               be changed to character, and the returned value will 
  1688. *--               also be character. The work involved is based on work
  1689. *--               by Miriam Liskin, Martin Leon, Clinton Warren,
  1690. *--               Joey D. Carol, and myself. 
  1691. *--               This Yes/No dialog box should do the following:
  1692. *--               A) Full 3-D effect(s)
  1693. *--               B) Color options up to programmer/user
  1694. *--               C) YES/NO buttons at bottom of dialog box
  1695. *--               D) Allow for location on screen
  1696. *--               E) Allow for up to 256 characters of text in message
  1697. *--               F) Give a "windows" like title bar
  1698. *--               G) Allow for screens bigger'n 25 lines ... (EGA43, 
  1699. *--                         VGA50 ...)
  1700. *-- Written for.: dBASE IV, 1.5 or later
  1701. *-- Rev. History: 06/24/1993 -- Original
  1702. *-- Calls.......: Shadow              Procedure in PROC.PRG
  1703. *--               Center              Procedure in PROC.PRG
  1704. *--               Bord3D              Procedure in PROC.PRG
  1705. *--               WordWrap            Procedure in PROC.PRG
  1706. *--               ColorBrk()          Function in PROC.PRG
  1707. *--               FBClrBrk()          Function in PROC.PRG
  1708. *--               Justify()           Function in PROC.PRG
  1709. *-- Called by...: Any
  1710. *-- Usage.......: x=YNC(<cDefault>,<cWhere>,<cTitle>,<cMessage>,;
  1711. *--                     <cColor>,<nStyle>)
  1712. *-- Example.....: x= YNC("Y","CC","Delete Record?",;
  1713. *--                          "If you select [Yes] "+;
  1714. *--                         "you will delete this record.",cWind1,3)
  1715. *--               do case
  1716. *--                  case x = "Y"
  1717. *--                       * do "Yes" action
  1718. *--                  case x = "N:
  1719. *--                       * do "No" action
  1720. *--                  otherwise
  1721. *--                       *-- do "Cancel" action
  1722. *--               endcase
  1723. *-- Returns.....: Character (first char of button)
  1724. *-- Parameters..: cDefault = Which menu pad do you wish to default to?
  1725. *--                          "Y" = "Yes", "N" = "No", "C" = "Cancel"
  1726. *--               cWhere   = Where on the screen do you wish the dialog 
  1727. *--                          box to appear?
  1728. *--                          UL = Upper Left
  1729. *--                          UC = Upper Center
  1730. *--                          UR = Upper Right
  1731. *--                          CL = Center Left
  1732. *--                          CC = Center Center (default)
  1733. *--                          CR = Center Right
  1734. *--                          BL = Bottom Left
  1735. *--                          BC = Bottom Center
  1736. *--                          BR = Bottom Right
  1737. *--               cTitle   = Title for the title bar, up to 30 chars
  1738. *--               cMessage = Message, up to 254 characters
  1739. *--               cColor   = Colors in standard foreground/background 
  1740. *--                          If no colors given, you will get the 
  1741. *--                          Borland "steel grey", with black text. 
  1742. *--                          The buttons and title bar will end up 
  1743. *--                          bright white on black.
  1744. *--               nStyle   = Border Style
  1745. *--                          1 = Double Border, raised (default)
  1746. *--                          2 = Double Border, recessed
  1747. *--                          3 = Single Border, raised
  1748. *--                          4 = Single Border, recessed
  1749. *-----------------------------------------------------------------------
  1750.  
  1751.    parameters cDefault, cWhere, cTitle, cMessage, cColor, nStyle
  1752.    private nParm,nWidth,nHeight,cRow,cCol,nTop,nBottom,nLeft,nRight,;
  1753.            cTempCol
  1754.    private nBordCol,nButtonRow,cWindow,cScreen,nScreen
  1755.    
  1756.    *-- save current screen, save current window
  1757.    m->cWindow = window()
  1758.    save screen to sYesNo
  1759.    
  1760.    *-- determine # of parameters passed, and set defaults if necessary
  1761.    m->nParm = pcount()
  1762.    if m->nParm < 6         && no selection for border-style, set to def.
  1763.       m->nStyle = 1
  1764.    endif
  1765.    if m->nStyle < 1 .or. m->nStyle > 4  && don't screw with _my_ routine!
  1766.       m->nStyle = 1
  1767.    endif
  1768.    if m->nParm < 5                   && no colors, set to steel-grey
  1769.       m->cColor = "N/W,W+/N,N/W"
  1770.    endif
  1771.    if isblank(m->cColor)
  1772.       m->cColor = "N/W,W+/N,N/W"
  1773.    endif
  1774.    if isblank(m->cWhere)         && default location is center of screen
  1775.       m->cWhere = "CC"
  1776.    endif
  1777.    
  1778.    *-- set some defaults
  1779.    m->nWidth = 36 + iif(m->nStyle < 3,4,2)    && width of dialog box
  1780.    
  1781.    *-- determine height of window by text
  1782.    *-- if the remainder of the length of the message/width is > 0
  1783.    *--    we have one more line of text, add 1, else add 0
  1784.    *-- border will determine more ... (if it's 1 or 2, it's double-size,
  1785.    *--    so we add 4 lines (top/bottom * 2), if it's 3 or 4, it's 
  1786.    *--    single ...)
  1787.    *-- add 2 rows for the title, and 3 for the menu, and 1 for the 
  1788.    *-- button borders ...
  1789.    m->nHeight = int(len(m->cMessage)/m->nWidth) + ;
  1790.              iif(mod(len(m->cMessage),m->nWidth) > 0,1,0) +;
  1791.              iif(m->nStyle < 3,3,1) +;
  1792.              6
  1793.    
  1794.    *-- now to determine window Coordinates
  1795.    m->cRow = left(m->cWhere,1)
  1796.    m->cCol = right(m->cWhere,1)
  1797.    
  1798.    *-- get screen height
  1799.    m->cScreen = SET("DISPLAY")
  1800.    if m->cScreen = "MONO"
  1801.       m->nScreen = 24
  1802.    else
  1803.       m->nScreen = val(right(m->cScreen,2)) - 1  && (EGA25 = 0 to 24)
  1804.    endif
  1805.    
  1806.    *-- this is where we _really_ determine the coordinates
  1807.    do case   && first let's get the rows (top/bottom)
  1808.       case m->cRow = "U"
  1809.          m->nTop = 1
  1810.       case m->cRow ="B"
  1811.          m->nTop = (m->nScreen - m->nHeight - 2) &&leave room for shadow
  1812.       otherwise  && "C" or center ...
  1813.          m->nTop = (m->nScreen - m->nHeight) / 2
  1814.    endcase
  1815.    m->nBottom = m->nTop + m->nHeight
  1816.    
  1817.    do case   && now for the columns
  1818.       case m->cCol = "L"
  1819.          m->nLeft = 5
  1820.       case m->cCol = "R"
  1821.          m->nLeft = 35
  1822.       otherwise && "C" or center
  1823.          m->nLeft = 20
  1824.    endcase
  1825.    m->nRight = m->nLeft + m->nWidth
  1826.    
  1827.    *-- define window
  1828.    activate screen
  1829.    define window wYesNo from m->nTop,m->nLeft to m->nBottom,m->nRight;
  1830.                   NONE color &cColor.
  1831.    
  1832.    *-- define menu
  1833.    define menu mYesNo
  1834.    m->nButtonRow = m->nHeight - iif(m->nStyle<3,3,2)
  1835.    m->nYes = 5                && column for "[Yes]"    button
  1836.    m->nNo  = (m->nWidth-6)/2  && column for "[No]"  button -- center it
  1837.    m->nCan = (m->nWidth-13)   && column for "[Cancel]" button 
  1838.    define pad pYes of mYesNo prompt "[Yes]"    at m->nButtonRow,m->nYes
  1839.    define pad pNo  of mYesNo prompt "[No]"     at m->nButtonRow,m->nNo
  1840.    define pad pCan of mYesNo prompt "[Cancel]" at m->nButtonRow,m->nCan
  1841.    on selection pad pYes of mYesNo deactivate menu
  1842.    on selection pad pNo  of mYesNo deactivate menu
  1843.    on selection pad pCan of mYesNo deactivate menu
  1844.    
  1845.    *-- activate window
  1846.    do shadow with m->nTop,m->nLeft,m->nBottom,m->nRight
  1847.    activate window wYesNo
  1848.    
  1849.    *-- draw border
  1850.    m->cBordCol = left(m->cColor,at(",",m->cColor)-1)
  1851.    do bord3d with 0,0,m->nHeight,m->nWidth,m->cBordCol,m->nStyle 
  1852.    
  1853.    *-- display title
  1854.    if len(m->cTitle) < m->nWidth
  1855.       m->cTitle = justify(m->cTitle,35,"C")
  1856.       if len(m->cTitle) < 35
  1857.          m->cTitle = m->cTitle + " "
  1858.       endif
  1859.    endif
  1860.    m->cTempCol = colorbrk(m->cColor,2)
  1861.    m->cColorF  = FBClrBrk("B",m->cTempCol)
  1862.    m->cColorB  = FBClrBrk("B",colorbrk(m->cColor,1))
  1863.    m->cColorAll= m->cColorF+"/"+m->cColorB
  1864.    m->nRow = iif(m->nStyle < 3,2,1)
  1865.    nCol = iif(m->nStyle < 3,3,2)
  1866.    @m->nRow,  m->nCol say m->cTitle color &cTempCol.
  1867.    @m->nRow+1,m->nCol say replicate(chr(223),35) color &cColorAll.
  1868.    
  1869.    *-- display text
  1870.    do WordWrap with iif(m->nStyle<3,4,3),iif(m->nStyle<3,4,3),;
  1871.                         m->cMessage,34
  1872.    
  1873.    *-- set Y/N keys for menu pad
  1874.    clear typeahead && just to be safe
  1875.    *-- if we're ON the pad user selected, do nothing, else go left or
  1876.    *-- right as needed, and then issue a "Return" (chr(13))
  1877.    on key label Y keyboard iif(pad() = "PYES","",;
  1878.       iif(pad()="PNO",chr(19),chr(4) ) )+chr(13)
  1879.    on key label N keyboard iif(pad() = "PNO" ,"",;
  1880.       iif(pad()="PYES",chr(4),chr(19) ) )+chr(13)
  1881.    on key label C keyboard iif(pad() = "PCAN","",;
  1882.       iif(pad()="PNO",chr(4),chr(19) ) )+chr(13)
  1883.    
  1884.    *-- deal with borders around the pads ...
  1885.    do bord3d with m->nButtonRow-1,m->nYes-1,m->nButtonRow+1,;
  1886.                   m->nYes+5,m->cBordCol,3
  1887.    do bord3d with m->nButtonRow-1,m->nNo-1, m->nButtonRow+1,;
  1888.                   m->nNo+4, m->cBordCol,3
  1889.    do bord3d with m->nButtonRow-1,m->nCan-1,m->nButtonRow+1,;
  1890.                   m->nCan+8,m->cBordCol,3
  1891.    
  1892.    *-- activate menu
  1893.    do case
  1894.       case upper(m->cDefault) = "Y"
  1895.          activate menu mYesNo pad pYes
  1896.       case upper(m->cDefault) = "N"
  1897.          activate menu mYesNo pad pNo
  1898.       case (m->cDefault) = "C"
  1899.          activate menu mYesNo pad pCan
  1900.       otherwise  && default to 'Yes'
  1901.          activate menu mYesNo pad pYes
  1902.    endcase
  1903.    
  1904.    *-- cleanup
  1905.    on key label Y
  1906.    on key label N
  1907.    on key label C
  1908.    release window wYesNo
  1909.    restore screen from sYesNo
  1910.    release screen sYesNo
  1911.    release menu mYesNo
  1912.    if .not. isblank(m->cWindow)
  1913.       activate window &cWindow.
  1914.    endif
  1915.          
  1916. RETURN substr(pad(),2,1)
  1917. *-- EoF: YNC()
  1918.  
  1919. *=======================================================================
  1920. * COLOR PROCESSING -- These routines handle setting colors, dealing with
  1921. * checking how colors are set, and so on. Anything that's not here is in
  1922. * the library file:  COLOR.PRG.
  1923. *=======================================================================
  1924.  
  1925. PROCEDURE SetColor
  1926. *-----------------------------------------------------------------------
  1927. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  1928. *-- Date........: 07/24/1992
  1929. *-- Notes.......: This routine is designed set colors of the primary 
  1930. *--               "areas" on the screen, based on a color memvar being 
  1931. *--               passed to it. This color memvar should contain two 
  1932. *--               sets of colors (normal and enhanced). See below for 
  1933. *--               more details.
  1934. *-- Written for.: dBASE IV, 1.5
  1935. *-- Rev. History: 07/24/1992 -- Original
  1936. *-- Calls.......: ColorBrk()           Function in PROC.PRG
  1937. *-- Called by...: Any
  1938. *-- Usage.......: do SetColor with <cColorVar>
  1939. *-- Example.....: cOldColor = set("ATTRIBUTES")  && save old colors
  1940. *--               do SetColor with cl_dialog
  1941. *--                 *-- do whatever needs to be done with these colors
  1942. *--               do ReColor with cOldColor      && restore old colors
  1943. *-- Returns.....: None
  1944. *-- Parameters..: cColorVar = Color memvar. This must contain a "normal"
  1945. *--                           color and a "highlight" color in the 
  1946. *--                           format:
  1947. *--                           <forg>/<back>,<forg>/<back>
  1948. *--                           i.e., "rg+/gb,w+/b"
  1949. *-----------------------------------------------------------------------
  1950.  
  1951.    parameters cColorVar
  1952.    private cNormCol,cHighCol
  1953.    
  1954.    m->cNormCol = colorbrk(m->cColorVar,1)  && extract "normal" colors
  1955.    m->cHighCol = colorbrk(m->cColorVar,2)  && extract "highlight" colors
  1956.    
  1957.    set color of normal    to &cNormCol. && regular screen/text colors
  1958.    set color of messages  to &cNormCol. && messages/menu pads, etc.
  1959.    set color of box       to &cHighCol. && borders
  1960.    set color of fields    to &cHighCol. && data entry fields
  1961.    set color of highlight to &cHighCol. && highlighted items in menus
  1962.    
  1963. RETURN
  1964. *-- EoP: SetColor
  1965.  
  1966. PROCEDURE ReColor
  1967. *-----------------------------------------------------------------------
  1968. *-- Programmer..: Jay Parsons (CIS: 72662,1302)
  1969. *-- Date........: 04/23/1992
  1970. *-- Notes.......: Restores colors to those held in a string of the form
  1971. *--               returned by set("ATTRIBUTE").
  1972. *-- Written for.: dBASE IV, Versions 1.0 - 1.5.
  1973. *-- Rev. History: 04/23/1992 -- Original
  1974. *-- Calls       : None
  1975. *-- Called by...: Any
  1976. *-- Usage.......: DO ReColor WITH <cColors>
  1977. *-- Example.....: DO Recolor WITH OldColors
  1978. *-- Parameters..: cColors, a string in the form returned by 
  1979. *--                        set("ATTRIBUTE").
  1980. *-- Side effects: Changes the screen colors.
  1981. *-----------------------------------------------------------------------
  1982.  
  1983.    parameters cColors
  1984.    private cThis, cNext, nAt, cLeft, nX, cAreas
  1985.  
  1986.    m->cAreas = "   NORMHIGHBORDMESSTITLBOX INFOFIEL"
  1987.    m->cLeft = m->cColors + ", "
  1988.    m->nX = 0
  1989.    do while m->nX < 8
  1990.       m->nX = m->nX + 1
  1991.       m->cThis = substr( m->cAreas, 4 * m->nX, 4 )
  1992.       if m->nX = 3
  1993.          m->nAt = at( "&", m->cLeft )
  1994.          m->cNext = left( m->cLeft, m->nAt - 2 )
  1995.          m->cLeft = substr( m->cLeft, m->nAt + 3 )
  1996.          SET COLOR TO , , &cNext.
  1997.       else
  1998.          m->nAt = at( ",", m->cLeft )
  1999.          m->cNext = left( m->cLeft, m->nAt - 1 )
  2000.          m->cLeft = substr( m->cLeft, m->nAt + 1 )
  2001.          SET COLOR OF &cThis. TO &cNext.
  2002.       endif
  2003.    enddo
  2004.  
  2005. RETURN
  2006. *-- EoP: ReColor
  2007.  
  2008. FUNCTION ColorBrk
  2009. *-----------------------------------------------------------------------
  2010. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  2011. *-- Date........: 03/24/1993
  2012. *-- Notes.......: This routine is designed to be used with any of my 
  2013. *--               functions and procedures that accept a memory variable
  2014. *--               for color, and use a window. It's purpose is to break 
  2015. *--               that color var into it's components (depending on 
  2016. *--               which one the user wants) and return those components,
  2017. *--               so that they can then be used in SET COLOR OF ... 
  2018. *--               commands.
  2019. *-- Written for.: dBASE IV, 1.1, 1.5 (written because of 1.5, but will 
  2020. *--               work in 1.1)
  2021. *-- Rev. History: 07/22/1992 - modified to handle memvars/color strings 
  2022. *--                 that may have only two parts to them (no 
  2023. *--                 <border>...), so that if the <nField> parm is 2, we
  2024. *--                 get a valid value.
  2025. *--               03/24/1993 -- Lee Hite - Fixed to work correctly when 
  2026. *--               <cColorVar> contains a single colorset (i.e., "b/w").
  2027. *-- Calls.......: None
  2028. *-- Called by...: Any
  2029. *-- Usage.......: ColorBrk(<cColorVar>,<nField>)
  2030. *-- Example.....: set color of normal to ColorBrk(cColor,1)
  2031. *-- Returns.....: Either the field you asked for (1 thru 3) or null 
  2032. *--                 string ("").
  2033. *-- Parameters..: cColorVar = Color variable to extract data from
  2034. *--                   Assumes the form: 
  2035. *--                         <main color>,<highlight>,<border>
  2036. *--                   Where each part uses: <foreground>/<background>
  2037. *--                     format: i.e., rg+/gb,w+/b,rg+/gb
  2038. *--               nField    = Field you want to extract
  2039. *-----------------------------------------------------------------------
  2040.  
  2041.    parameters cColorVar, nField
  2042.    private cReturn, cExtracted
  2043.    
  2044.    do case
  2045.       case m->nField = 1
  2046.          if at(",",m->cColorVar) > 0
  2047.             m->cReturn = left(m->cColorVar,at(",",m->cColorVar)-1)
  2048.          else
  2049.             m->cReturn = m->cColorVar
  2050.          endif
  2051.       case m->nField = 2
  2052.          m->cExtract = substr(m->cColorVar,at(",",m->cColorVar)+1)  
  2053.                            && everything to the right of comma
  2054.          if at(",",m->cExtract) > 0
  2055.             m->cReturn = left(m->cExtract,at(",",m->cExtract)-1)    
  2056.                            && left of second comma
  2057.          else
  2058.             m->cReturn = m->cExtract
  2059.          endif
  2060.       case m->nField = 3
  2061.          m->cExtract = substr(m->cColorVar,at(",",m->cColorVar)+1)
  2062.          if at(",",m->cExtract) > 0
  2063.             m->cReturn = substr(m->cExtract,at(",",m->cExtract)+1)
  2064.          else
  2065.             m->cReturn = ""
  2066.          endif
  2067.       otherwise
  2068.          m->cReturn = ""
  2069.    endcase
  2070.  
  2071. RETURN m->cReturn
  2072. *-- EoF: ColorBrk()
  2073.  
  2074. FUNCTION FBClrBrk
  2075. *-----------------------------------------------------------------------
  2076. *-- Programmer..: Joey D. Carroll (JOEY on USSBBS)
  2077. *-- Date........: 11/12/1992
  2078. *-- Notes.......: Extracts foreground/background colors from a string in
  2079. *--               the form of a literal "n/gb" or of a variable.  It is 
  2080. *--               useful to use COLORBRK() to obtain this value.
  2081. *-- Written for.: dBASE IV, ver 1.5
  2082. *-- Rev. History: 11/12/1992 -- Original
  2083. *-- Calls.......: None
  2084. *-- Called by...: Any
  2085. *-- Usage.......: ?? FBClrBrk("B","w+/gr")
  2086. *-- Example.....: cNormalClr = "w+/gr"
  2087. *--               cForeClr   = FBClrBrk("F",cNormalClr)   && = "w+"
  2088. *--               cBackClr   = FBClrBrk("B",cNormalClr)   && = "gr"
  2089. *-- Returns.....: a sub-string of cColor
  2090. *-- Parameters..: cType  = "F" for foreground color  "B" for Background
  2091. *--               cColor = the color you want to extract from
  2092. *-----------------------------------------------------------------------
  2093.  
  2094.    parameters cType,cColor
  2095.    private cRetClr
  2096.  
  2097.    if upper(m->cType) = "F"
  2098.        m->cRetClr = iif(at("/",m->cColor) = 0,m->cColor,left(m->cColor,;
  2099.                      at("/",m->cColor)-1))
  2100.    else           && = "B"
  2101.       m->cRetClr = substr(m->cColor,at("/",m->cColor) + 1,2)
  2102.    endif
  2103.  
  2104. RETURN m->cRetClr
  2105. *-- EoF: FBClrBrk()
  2106.  
  2107. FUNCTION BackColor
  2108. *-----------------------------------------------------------------------
  2109. *-- Programmer..: Jay Parsons (CIS: 72662,1302)
  2110. *-- Date........: 02/24/1993
  2111. *-- Notes       : Returns background part of color string.
  2112. *-- Written for.: dBASE IV, Version 1.5.
  2113. *-- Rev. History: 02/04/1993 -- Original Release
  2114. *-- Calls       : None
  2115. *-- Called by...: Any
  2116. *-- Usage.......: BackColor( <cColor> )
  2117. *-- Example.....: ? BackColor( "N/BG" )
  2118. *-- Parameters..: cColor    -   String holding color foreground and 
  2119. *--                             background
  2120. *-- Returns.....: Character, string with background portion of the 
  2121. *--               color. Returns empty string if no such portion.
  2122. *-----------------------------------------------------------------------
  2123.  
  2124.    parameters cColor
  2125.    private m->cRet
  2126.  
  2127.    m->cRet = upper( trim( ltrim( m->cColor ) ) )
  2128.    if "/" $ m->cRet
  2129.       m->cRet = substr( m->cRet, at( "/", m->cRet ) + 1 )
  2130.       if "*" $ m->cRet
  2131.          m->cRet = stuff( m->cRet, at( "*", m->cRet ), 1, "" )
  2132.       endif
  2133.       if "+" $ m->cRet 
  2134.          m->cRet = stuff( m->cRet, at( "+", m->cRet ), 1, "" )
  2135.       endif
  2136.    else
  2137.       m->cRet = ""
  2138.    endif
  2139.  
  2140. RETURN upper( ltrim( trim( m->cRet ) ) )
  2141. *-- EoF: BackColor()
  2142.  
  2143. *=======================================================================
  2144. * STRING Manipulation. Most of these are in the library file:  
  2145. * STRINGS.PRG. The ones here are common to a lot of apps and functions, 
  2146. * and are here so that the library STRINGS.PRG need not be called.
  2147. *=======================================================================
  2148.  
  2149. FUNCTION AllTrim
  2150. *-----------------------------------------------------------------------
  2151. *-- Programmer..: Phil Steele (from PCSDEMO.PRG -- Public Domain)
  2152. *-- Date........: 05/23/1991
  2153. *-- Notes.......: Complete trims edges of field (left and right)
  2154. *-- Written for.: dBASE IV, 1.1
  2155. *-- Rev. History: 05/23/1991 -- Original
  2156. *-- Calls.......: None
  2157. *-- Called by...: Any
  2158. *-- Usage.......: alltrim(<cString>)
  2159. *-- Example.....: ? alltrim("  Test String  ") 
  2160. *-- Returns.....: Trimmed string, i.e.:"Test String"
  2161. *-- Parameters..: cString = string to be trimmed
  2162. *-----------------------------------------------------------------------
  2163.    
  2164.    parameters cString
  2165.    
  2166. RETURN ltrim(rtrim(m->cString))
  2167. *-- EoF: AllTrim()
  2168.  
  2169. FUNCTION Justify
  2170. *-----------------------------------------------------------------------
  2171. *-- Programmer..: Roland Bouchereau (Ashton-Tate/Borland)
  2172. *-- Date........: 03/24/1993
  2173. *-- Notes.......: Used to pad a field/string on the right, left or both,
  2174. *--               justifying or centering it within the length 
  2175. *--               specified. If the length of the string passed is 
  2176. *--               greater than the size needed, the function will 
  2177. *--               truncate it. Taken from Technotes, June 1990. Defaults
  2178. *--               to Left Justify if invalid TYPE is passed ...
  2179. *-- Written for.: dBASE IV, 1.0
  2180. *-- Rev. History: Original function 06/15/1991
  2181. *--               12/17/1991 -- Modified into ONE function from three by
  2182. *--                  Ken Mayer, added a third parameter to handle that.
  2183. *--               12/23/1992 -- Modified by Joey Carroll to use STUFF()
  2184. *--                  instead of TRANSFORM().
  2185. *--               03/24/1993 -- Modified by Lee Hite, as the center
  2186. *--                  option wasn't working quite right ...
  2187. *-- Calls.......: None
  2188. *-- Called by...: Any
  2189. *-- Usage.......: Justify(<cFld>,<nLength>,"<cType>")
  2190. *-- Example.....: ?? Justify(Address,25,"R")
  2191. *-- Returns.....: Padded/truncated field
  2192. *-- Parameters..: cFld    =  Field/Memvar/Character String to justify
  2193. *--               nLength =  Width to justify within
  2194. *--               cType   =  Type of justification: L=Left, C=Center,
  2195. *--                                                 R=Right
  2196. *-----------------------------------------------------------------------
  2197.    
  2198.    parameters cFld,nLength,cType
  2199.    private cReturn
  2200.    
  2201.    m->cType = upper(m->cType)    && just making sure ...
  2202.    if type("m->cFld")+type("m->nLength")+type("m->cType") $ "CNC,CFC"
  2203.       *-- set a picture function of 'X's, with @I,@J or @B function
  2204.       m->cReturn = space(m->nLength)
  2205.       m->cReturn = stuff(m->cReturn,;
  2206.             iif(m->cType = "C",((m->nLength-len(m->cFld))/2)+1,;
  2207.             iif(m->cType = "R",m->nLength-len(m->cFld)+1,1)),;
  2208.             len(m->cFld),m->cFld)
  2209.    else
  2210.       m->cReturn = ""
  2211.    endif
  2212.  
  2213. RETURN m->cReturn
  2214. *-- EoF: Justify()
  2215.  
  2216. FUNCTION State
  2217. *-----------------------------------------------------------------------
  2218. *-- Programmer..: David G. Franknbach (CIS: 72147,263)
  2219. *-- Date........: 04/22/1992
  2220. *-- Notes.......: Validation of state codes -- used to ensure that a 
  2221. *--               user doing data entry will enter the proper codes. 
  2222. *--               Added a few US Territory codes as well (Puerto Rico,
  2223. *--               etc.)
  2224. *-- Written for.: dBASE IV, 1.1
  2225. *-- Rev. History: 12/02/1991
  2226. *--               03/11/1992 -- Modified by Ken Mayer to handle
  2227. *--               the extra US Territories, and to ensure that the data 
  2228. *--               is at least temporarily in upper case when doing the 
  2229. *--               check ...
  2230. *--               04/22/1992 -- Modified by Jay Parsons to shorten
  2231. *--               (simplify) the routine by removing the cSTATE2 memvar.
  2232. *-- Calls.......: None
  2233. *-- Called by...: None
  2234. *-- Usage.......: STATE(<cState>)
  2235. *-- Example.....: @5,10 get cState valid required state(cState);
  2236. *--                     error chr(7)+"This is not a valid state code!"
  2237. *-- Returns.....: Logical (.t. if found, .f. otherwise)
  2238. *-- Parameters..: cState = state code to be checked ....
  2239. *-----------------------------------------------------------------------
  2240.  
  2241.    parameters cState
  2242.    
  2243.    m->cStateList = "AL|AK|AZ|AR|CA|CO|CT|DE|DC|FL|GA|HI|ID|IL|IN|IA|"+;
  2244.            "KS|KY|LA|ME|MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|"+;
  2245.            "OH|OK|OR|PA|RI|SC|SD|TN|TX|UT|VT|VA|WA|WV|WI|WY|PR|AS|GU|"+;
  2246.            "CM|TT|VI|"
  2247.    m->lOK = upper(m->cState) $ m->cStateList
  2248.  
  2249. RETURN m->lOK
  2250. *-- EoF: State()
  2251.  
  2252. PROCEDURE WordWrap
  2253. *-----------------------------------------------------------------------
  2254. *-- Programmer..: David Frankenbach (CIS: 72147,2635)
  2255. *-- Date........: 01/14/1993 (Version 1.1)
  2256. *-- Notes.......: Wraps a long string, breaking it into strings that 
  2257. *--               have a maximum length of nWidth. The first output is 
  2258. *--               displayed @nRow, nCol. Words are not split ...
  2259. *-- Written for.: dBASE IV, 1.5
  2260. *-- Rev. History: 01/06/1993 -- Original Release (Version 1.0)
  2261. *--               01/14/1993 -- Version 1.1 -- Corrected side-effect of 
  2262. *--                       destroying string arg, added test for 
  2263. *--                       string[nWidth+1] = " "
  2264. *-- Calls.......: None
  2265. *-- Called by...: Any
  2266. *-- Usage.......: do WordWrap with <nRow>, <nCol>, <cString>, <nWidth>
  2267. *-- Example.....: do WordWrap with 2,2,cText,38
  2268. *-- Returns.....: None
  2269. *-- Parameters..: nRow     = Row to display first line at
  2270. *--               nCol     = Left side of area to display text at
  2271. *--               cString  = text to wrap
  2272. *--               nWidth   = Width of area to wrap text in
  2273. *-----------------------------------------------------------------------
  2274.  
  2275.    parameters nRow, nCol, cString, nWidth
  2276.    private cTemp, nI, cStr
  2277.    
  2278.    m->cStr = m->cString        && work with a COPY of input, to avoid
  2279.                                && destroying original
  2280.    
  2281.    do while len(m->cStr) > 0      && while there's something to work on
  2282.       if (m->nWidth < len(m->cStr))
  2283.          m->nI = m->nWidth        && look for last " " in first nWidth
  2284.          
  2285.          if substr(m->cStr,m->nI+1,1) # " "
  2286.             do while ( (m->nI > 0) .and. (substr(m->cStr,m->nI,1)# " "))
  2287.                m->nI = m->nI - 1
  2288.             enddo
  2289.          endif
  2290.          
  2291.          if m->nI = 0                 && no spaces
  2292.             m->nI = m->nWidth         && get first nWidth characters
  2293.           endif                   
  2294.        else
  2295.          m->nI = len(m->cStr)         && use the rest of the string
  2296.       endif
  2297.       
  2298.       m->cTemp = left(m->cStr,m->nI)  && get the part we're going to 
  2299.                                       && display
  2300.       
  2301.       if m->nI < len(m->cStr)         && remove that part
  2302.          m->cStr = ltrim(substr(m->cStr,m->nI + 1))
  2303.       else
  2304.          m->cStr = ""
  2305.       endif
  2306.       
  2307.       *-- display it
  2308.       @m->nRow,m->nCol say m->cTemp
  2309.       *-- move to next row
  2310.       m->nRow = m->nRow + 1
  2311.       
  2312.    enddo
  2313.    
  2314. RETURN
  2315. *-- EoP: WordWrap
  2316.  
  2317. *=======================================================================
  2318. *  DATE HANDLING ROUTINES -- Most of these are now in the library file: 
  2319. *  DATES.PRG (included with this version of PROC). However, a few are 
  2320. *  below, as they have become 'standard' routines in many of my systems.
  2321. *=======================================================================
  2322.  
  2323. FUNCTION DateText
  2324. *-----------------------------------------------------------------------
  2325. *-- Programmer..: Miriam Liskin
  2326. *-- Date........: 05/23/1991
  2327. *-- Notes.......: Display date in format Month, day year (e.g., 
  2328. *--               July 1, 1991)
  2329. *-- Written for.: dBASE IV, 1.1
  2330. *-- Rev. History: 05/23/1991 -- Original
  2331. *-- Calls.......: None
  2332. *-- Called by...: Any
  2333. *-- Usage.......: DateText(<dDate>) 
  2334. *-- Example.....: ? datetext(date())
  2335. *-- Returns.....: July 1, 1991
  2336. *-- Parameters..: dDate = date to be converted
  2337. *-----------------------------------------------------------------------
  2338.  
  2339.    parameters dDate
  2340.    
  2341. RETURN CMONTH(m->dDate)+" "+ltrim(str(day(m->dDate),2))+", "+;
  2342.                         str(year(m->dDate),4)
  2343. *-- EoF: DateText()
  2344.  
  2345. FUNCTION DateText2
  2346. *-----------------------------------------------------------------------
  2347. *-- Programmer..: Miriam Liskin
  2348. *-- Date........: 05/23/1991
  2349. *-- Notes.......: Display date in format day-of-week, Month day, year
  2350. *-- Written for.: dBASE IV, 1.1
  2351. *-- Rev. History: 05/23/1991 -- Original
  2352. *-- Calls.......: None
  2353. *-- Called by...: Any
  2354. *-- Usage.......: DateText2(<dDate>)
  2355. *-- Example.....: ? DateText2(date())
  2356. *-- Returns.....: Thursday, July 1, 1991
  2357. *-- Parameters..: dDate = date to be converted
  2358. *-----------------------------------------------------------------------
  2359.  
  2360.    parameters dDate
  2361.    
  2362. RETURN CDOW(m->dDate)+", "+cmonth(m->dDate)+" "+;
  2363.        ltrim(str(day(m->dDate),2))+", "+str(year(m->dDate),4)
  2364. *-- EoF: DateText2()
  2365.  
  2366. FUNCTION Age
  2367. *-----------------------------------------------------------------------
  2368. *-- Programmer..: Martin Leon (HMAN)
  2369. *-- Date........: 10/23/1991
  2370. *-- Notes.......: Returns age of person, given their birthdate as of 
  2371. *--               DATE(), effectively, as of "Today".
  2372. *-- Written for.: dBASE IV, 1.1
  2373. *-- Rev. History: 10/23/1991 -- Original
  2374. *--               08/10/1993 -- Went and "stole" code from the
  2375. *--                routine AGE2() in DATES.PRG, Zak and Jay Parsons ...
  2376. *--                It's more efficient.
  2377. *-- Calls.......: None
  2378. *-- Called by...: Any
  2379. *-- Usage.......: Age(<dBDay>)
  2380. *-- Example.....: ? "Joe is "+ltrim(str(age(dBDay)))+" today ..."
  2381. *-- Returns.....: Numeric value in years
  2382. *-- Parameters..: dBDay = birthdate of person attempting to find age of.
  2383. *-----------------------------------------------------------------------
  2384.  
  2385.    parameters dBDay
  2386.    
  2387. RETURN floor( ( val( dtos( date() ) ) - val( dtos( dBDay ) ) ) ;
  2388.               / 10000 )
  2389. *-- EoF: Age()
  2390.  
  2391. *=======================================================================
  2392. * MISC ROUTINES -- Ones that don't fit into other categories, quite ... 
  2393. * but are none-the-less very useful ... many of these routines have been
  2394. * placed in the library file:  MISC.PRG.
  2395. *=======================================================================
  2396.  
  2397. FUNCTION DosRun
  2398. *-----------------------------------------------------------------------
  2399. *-- Programmer..: Michael P. Dean (Ashton-Tate)
  2400. *-- Date........: 05/01/1992
  2401. *-- Notes.......: A routine to run a DOS program, checks to see if a
  2402. *--               window is active -- if so, it avoids the inevitable
  2403. *--               "Press any key to continue" and the subsequent messing
  2404. *--               up of the screen display.
  2405. *-- Written for.: dBASE IV, 1.1
  2406. *-- Rev. History: Pulled from A-T BBS 
  2407. *--               05/13/1991 - modified by Ken Mayer to use the DBASE
  2408. *--               RUN() function, rather than the ! or RUN commands.
  2409. *--               (suggested by Clinton L. Warren (VBCES).)
  2410. *--               Minor additions for screens from "Bosephus" on ATBBS 
  2411. *--               10/31/91 
  2412. *--               12/14/1991 - modified by Jim Magnant (TXAGGIE) to 
  2413. *--                deactivate and reactivate up to 10 windows ...
  2414. *--               04/21/1992 -- Modified for dBASE IV, 1.5 to use memory 
  2415. *--                handling parameters (.t.,<command>,.t.) of RUN() 
  2416. *--                function.
  2417. *--               05/01/1992 -- Modified to allow use with EITHER 1.1 or 
  2418. *--                1.5. By calling VERSION() without a parm, the version 
  2419. *--                of dBASE or RUNTIME is the last three characters on 
  2420. *--                the right. Taking the VAL() of that, we can ask if 
  2421. *--                the version is => 1.5 and process from there.
  2422. *-- Calls.......: None
  2423. *-- Called by...: Any
  2424. *-- Usage.......: DosRun(<cCmd>)
  2425. *-- Example.....: ndummy = dosrun("DIR /W /P")
  2426. *--                 * or
  2427. *--               ndummy = dosrun(memvar)  && where memvar contains dos
  2428. *--                                        && command and parameters ...
  2429. *-- Returns.....: Nul
  2430. *-- Parameters..: cCmd = Command (and parameters) to be executed
  2431. *-----------------------------------------------------------------------
  2432.  
  2433.    parameter cCmd
  2434.    private aWindow, n, nRun
  2435.    
  2436.    save screen to sDOS   && save screen ...
  2437.    m->n = 0              && set to 0 in case there are NO Windows active
  2438.    declare aWindow[10]
  2439.    aWindow[1] = window()           && grab window name of current window
  2440.    if len(trim(aWindow[1])) > 0    && if there's a window, deactivate
  2441.       m->n = 1 
  2442.       do while len(trim(aWindow[m->n])) > 0 && if there are more windows
  2443.          deactivate window &aWindow.[n]     &&   deactivate them, too
  2444.          m->n = m->n + 1
  2445.          aWindow[m->n] = window()
  2446.       enddo
  2447.    endif
  2448.    set console off                   && don't display to screen
  2449.    if val(right(version(),3)) => 1.5 && check version number. If > 1.5
  2450.       nRun = run(.t.,"&cCmd.",.t.)   &&  use complete swapping of dBASE,
  2451.                                      &&   etc.
  2452.    else                              && else it's 1.1 or 1.0
  2453.       nRun = run("&cCmd.")           && use older version of RUN() 
  2454.                                      &&    function
  2455.    endif
  2456.    set console on                    && ok, display to screen
  2457.    m->n = m->n - 1                   && compensate for final n=n+1
  2458.    if len(trim(aWindow[1])) > 1   && if there's a window, 
  2459.       do while m->n > 0              && reactivate all but last 
  2460.          activate window &aWindow.[m->n]  && activate
  2461.          m->n = m->n - 1             && decrement stack
  2462.       enddo
  2463.       activate window &aWindow.[1]   && activate final window ...
  2464.    endif
  2465.    restore screen from sDOS
  2466.    release screen sDOS
  2467.    
  2468. RETURN ""
  2469. *-- EoF: DosRun()
  2470.  
  2471. FUNCTION ScrnRpt
  2472. *-----------------------------------------------------------------------
  2473. *-- Programmer..: Bryan Flynn (AT/BOR-BBS)
  2474. *-- Date........: 10/31/1991
  2475. *-- Notes.......: Used to display a dBASE Report on screen, allowing 
  2476. *--               pauses when the screen is full.
  2477. *-- Written for.: dBASE IV, 1.1
  2478. *-- Rev. History: Changed by a lot of people to current version.
  2479. *-- Calls.......: None
  2480. *-- Called by...: Any
  2481. *-- Usage.......: ?ScrnRpt("<cRpt cArg>")
  2482. *-- Example.....: ?ScrnRpt("FT_REP1 FOR PROB='HPEQUIP'")
  2483. *-- Returns.....: ""  (Nul)
  2484. *-- Parameters..: cRpt  = Name of report with any arguments for command 
  2485. *--                       line
  2486. *-----------------------------------------------------------------------
  2487.  
  2488.    Parameter cRpt
  2489.    private lPWait, nPLength, cEscape
  2490.    
  2491.    *-- save system variables
  2492.    m->lPWait   = _pwait
  2493.    m->nPLength = _plength
  2494.    m->cEscape  = SET("ESCAPE")
  2495.    *-- set new variables
  2496.    _pwait   = .t.
  2497.    _plength = iif("43" $ SET("DISPLAY"),40,25)  
  2498.                            && if EGA43, set to 40, else 25
  2499.    set escape on
  2500.    
  2501.    *-- store current screen
  2502.    save screen to sTemp
  2503.    clear
  2504.  
  2505.    *-- set printer to nowhere and generate report
  2506.    set printer to nul
  2507.    report form &cRpt. noeject to print
  2508.  
  2509.    *-- set things back to normal
  2510.    set escape &cEscape.
  2511.    set printer to LPT1
  2512.    wait
  2513.    clear
  2514.    restore screen from sTemp
  2515.    release screen sTemp
  2516.    _pwait   = m->lPWait
  2517.    _plength = m->nPLength
  2518.  
  2519. RETURN ""
  2520. *-- EoF: ScrnRpt()
  2521.  
  2522. PROCEDURE SetMouse
  2523. *-----------------------------------------------------------------------
  2524. *-- Programmer..: Kenneth J. Mayer (CIS: 71333,1030)
  2525. *-- Date........: 03/11/1993
  2526. *-- Notes.......: Allows user to toggle mouse on/off.
  2527. *-- Written for.: dBASE IV, 2.0
  2528. *-- Rev. History: 03/11/1993 -- Original
  2529. *-- Calls.......: None
  2530. *-- Called by...: Any
  2531. *-- Usage.......: Do SetMouse 
  2532. *-- Example.....: c_Mouse = "ON"
  2533. *--               on key label alt-m do setmouse 
  2534. *-- Returns.....: None
  2535. *-- Parameters..: c_Mouse = 'current' status of mouse -- this is a 
  2536. *--                         public memvar, and should be defined as 
  2537. *--                         such. This routine will change the status 
  2538. *--                         of said memvar if it exists, or return if 
  2539. *--                         it does not.
  2540. *--                    c_Mouse is not _really_ a parameter ... 
  2541. *-----------------------------------------------------------------------
  2542.  
  2543.    if type("m->c_Mouse") = "L" .or. type("m->c_Mouse") = "U"
  2544.       RETURN
  2545.    endif
  2546.  
  2547.    if upper(m->c_Mouse) = "ON"
  2548.       set mouse off
  2549.       m->c_Mouse = "OFF"
  2550.    else
  2551.       set mouse on
  2552.       m->c_Mouse = "ON"
  2553.    endif
  2554.    
  2555. RETURN
  2556. *-- EoP: SetMouse
  2557.  
  2558. FUNCTION SwitchLib
  2559. *-----------------------------------------------------------------------
  2560. *-- Programmer..: Ken Mayer (CIS: 71333,1030)
  2561. *-- Date........: 05/01/1992
  2562. *-- Notes.......: Used with dBASE IV, 1.5 to switch LIBRARY files. It's 
  2563. *--               designed as a quick toggle between libraries. See 
  2564. *--               example below.
  2565. *-- Written for.: dBASE IV, 1.5
  2566. *-- Rev. History: 05/01/1992 -- Original
  2567. *-- Calls.......: None
  2568. *-- Called by...: Any
  2569. *-- Usage.......: SwitchLib(<cNewLib>)
  2570. *-- Example.....: cOldLib = SwitchLib("FILES")
  2571. *--               *-- execute function/procedure needed
  2572. *--               cOldLib = SwitchLib("&cOldLib")
  2573. *-- Returns.....: Old Library setting
  2574. *-- Parameters..: cNewLib = Library file you wish to change to. If the 
  2575. *--                         file extension is not '.PRG', you should add 
  2576. *--                         the file extension to the description (I.e, 
  2577. *--                         "FILES.LIB")
  2578. *-----------------------------------------------------------------------
  2579.    
  2580.    parameters cNewLib
  2581.    private cCurLib
  2582.    
  2583.    m->cCurLib = set("LIBRARY")
  2584.    set library to &cNewLib.
  2585.    
  2586. RETURN m->cCurLib
  2587. *-- EoF: SwitchLib()
  2588.  
  2589. FUNCTION VerLevel
  2590. *-----------------------------------------------------------------------
  2591. *-- Programmer..: Bowen Moursund (CIS: 72662,436)
  2592. *-- Date........: 06/24/1992
  2593. *-- Notes.......: Returns the numeric version number of the current 
  2594. *--               version of dBASE or RUNTIME. Useful in version 
  2595. *--               specific routines.
  2596. *-- Written for.: dBASE IV, 1.5
  2597. *-- Rev. History: 06/24/1992 -- Original
  2598. *-- Calls.......: None
  2599. *-- Called by...: Any
  2600. *-- Usage.......: VerLevel()
  2601. *-- Example.....: if VerLevel() >= 1.5
  2602. *-- Returns.....: a numeric equivalent of Version()
  2603. *-- Parameters..: None
  2604. *-----------------------------------------------------------------------
  2605.  
  2606.     private cVersion, nPos
  2607.  
  2608.     m->cVersion = version()
  2609.     m->nPos = 1
  2610.     do while left(right(m->cVersion,m->nPos),1) # " "
  2611.        m->nPos = m->nPos + 1
  2612.     enddo
  2613.  
  2614. RETURN val(right(m->cVersion,m->nPos+1))
  2615. *-- Eof() VerLevel
  2616.  
  2617. *=======================================================================
  2618. *-- End of Procedure File -- PROC.PRG
  2619. *=======================================================================
  2620.